diff --git a/OCH/common/biz/src/main/java/com/mogo/och/biz/login/ui/LoginFragment.kt b/OCH/common/biz/src/main/java/com/mogo/och/biz/login/ui/LoginFragment.kt index 7c3d920355..5ff1b226cf 100644 --- a/OCH/common/biz/src/main/java/com/mogo/och/biz/login/ui/LoginFragment.kt +++ b/OCH/common/biz/src/main/java/com/mogo/och/biz/login/ui/LoginFragment.kt @@ -51,6 +51,7 @@ import kotlinx.android.synthetic.main.biz_login_view.biz_cl_driver_main import kotlinx.android.synthetic.main.biz_login_view.biz_login_svp import kotlinx.android.synthetic.main.biz_login_view.bv_switch_business import kotlinx.android.synthetic.main.biz_login_view.cl_login_info +import kotlinx.android.synthetic.main.biz_login_view.cl_welcome_info import kotlinx.android.synthetic.main.biz_login_view.eiv_Info import kotlinx.android.synthetic.main.biz_login_view.viewColdStart import me.jessyan.autosize.utils.AutoSizeUtils @@ -67,6 +68,9 @@ class LoginFragment : MvpFragment(), ILoginView private var showLoginInfoAnimator1: ObjectAnimator? = null private var showLoginInfoAnimator2: ObjectAnimator? = null + private var showLoginInfoAnimator11: ObjectAnimator? = null + private var showLoginInfoAnimator22: ObjectAnimator? = null + private var onlayoutListener: OnGlobalLayoutListener? = object : OnGlobalLayoutListener { override fun onGlobalLayout() { try { @@ -287,7 +291,10 @@ class LoginFragment : MvpFragment(), ILoginView } } if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) { - mPresenter?.autoLogin() + cl_welcome_info?.visibility = View.VISIBLE + UiThreadHandler.postDelayed({ + mPresenter?.autoLogin() + }, 2_000, UiThreadHandler.MODE.QUEUE) } else { cl_login_info?.visibility = View.VISIBLE } @@ -314,45 +321,83 @@ class LoginFragment : MvpFragment(), ILoginView } }) - if (showLoginInfoAnimator1 == null) { - showLoginInfoAnimator1 = ObjectAnimator.ofFloat(cl_login_info, "alpha", 0f, 1f) - showLoginInfoAnimator1?.interpolator = LinearInterpolator() - } - if (showLoginInfoAnimator2 == null) { - val dp2px = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(), -50f) - showLoginInfoAnimator2 = ObjectAnimator.ofFloat(cl_login_info, "translationY", 0f, dp2px.toFloat()) - showLoginInfoAnimator2?.interpolator = DecelerateInterpolator() - } - UiThreadHandler.postDelayed({ - cl_login_info?.let { - val animatorSet = AnimatorSet() - animatorSet.playTogether(showLoginInfoAnimator1, showLoginInfoAnimator2) - animatorSet.duration = 500 - animatorSet.addListener(object :AnimatorListener{ - override fun onAnimationStart(animation: Animator) { - if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) { - mPresenter?.autoLogin() - } else { + if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) { + if (showLoginInfoAnimator11 == null) { + showLoginInfoAnimator11 = ObjectAnimator.ofFloat(cl_welcome_info, "alpha", 0f, 1f) + showLoginInfoAnimator11?.interpolator = LinearInterpolator() + } + if (showLoginInfoAnimator22 == null) { + val dp2px = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(), -50f) + showLoginInfoAnimator22 = ObjectAnimator.ofFloat(cl_welcome_info, "translationY", 0f, dp2px.toFloat()) + showLoginInfoAnimator22?.interpolator = DecelerateInterpolator() + } + UiThreadHandler.postDelayed({ + cl_welcome_info?.let { + val animatorSet = AnimatorSet() + animatorSet.playTogether(showLoginInfoAnimator11, showLoginInfoAnimator22) + animatorSet.duration = 500 + animatorSet.addListener(object : AnimatorListener { + override fun onAnimationStart(animation: Animator) { + cl_welcome_info?.visibility = View.VISIBLE + UiThreadHandler.postDelayed({ + mPresenter?.autoLogin() + }, 4_000, UiThreadHandler.MODE.QUEUE) + + } + + override fun onAnimationEnd(animation: Animator) { + + } + + override fun onAnimationCancel(animation: Animator) { + + } + + override fun onAnimationRepeat(animation: Animator) { + + } + + }) + animatorSet.start() + } + }, 1_000, UiThreadHandler.MODE.QUEUE) + } else { + if (showLoginInfoAnimator1 == null) { + showLoginInfoAnimator1 = ObjectAnimator.ofFloat(cl_login_info, "alpha", 0f, 1f) + showLoginInfoAnimator1?.interpolator = LinearInterpolator() + } + if (showLoginInfoAnimator2 == null) { + val dp2px = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(), -50f) + showLoginInfoAnimator2 = ObjectAnimator.ofFloat(cl_login_info, "translationY", 0f, dp2px.toFloat()) + showLoginInfoAnimator2?.interpolator = DecelerateInterpolator() + } + UiThreadHandler.postDelayed({ + cl_login_info?.let { + val animatorSet = AnimatorSet() + animatorSet.playTogether(showLoginInfoAnimator1, showLoginInfoAnimator2) + animatorSet.duration = 500 + animatorSet.addListener(object :AnimatorListener{ + override fun onAnimationStart(animation: Animator) { cl_login_info?.visibility = View.VISIBLE } - } - override fun onAnimationEnd(animation: Animator) { + override fun onAnimationEnd(animation: Animator) { - } + } - override fun onAnimationCancel(animation: Animator) { + override fun onAnimationCancel(animation: Animator) { - } + } - override fun onAnimationRepeat(animation: Animator) { + override fun onAnimationRepeat(animation: Animator) { - } + } - }) - animatorSet.start() - } - },2_000,UiThreadHandler.MODE.QUEUE) + }) + animatorSet.start() + } + },2_000,UiThreadHandler.MODE.QUEUE) + } biz_login_svp?.startPlayLogic() } } diff --git a/OCH/common/biz/src/main/res/layout/biz_login_view.xml b/OCH/common/biz/src/main/res/layout/biz_login_view.xml index 5a1c9133a2..ad5a5ad57d 100644 --- a/OCH/common/biz/src/main/res/layout/biz_login_view.xml +++ b/OCH/common/biz/src/main/res/layout/biz_login_view.xml @@ -14,6 +14,31 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + + + (), IOchBizFunctionCall4Eagle { @@ -19,6 +20,10 @@ object OchTransform : CallerBase(), IOchBizFunctionCall4Ea } } + override fun isLogin(): Boolean { + return LoginStatusManager.isLogin() + } + override fun setVideoView(target: View?) { OchChainLogManager.writeChainLogEye("鹰眼调用och","展示司机端视频流:${target}") M_LISTENERS.forEach { diff --git a/OCH/facade/script/och.gradle b/OCH/facade/script/och.gradle index f4dc67ab14..e1db771835 100644 --- a/OCH/facade/script/och.gradle +++ b/OCH/facade/script/och.gradle @@ -8,6 +8,7 @@ project.dependencies { implementation project.project(':OCH:offline:driver') implementation project.project(':OCH:sweeper:driver') implementation project.project(':OCH:shuttle:driver_weaknet') + implementation project.project(':OCH:shuttle:driver_unmanned') implementation project.project(':OCH:charter:driver') implementation project.project(':OCH:taxi:unmanned-driver') }else if(isPassenger()){ @@ -17,6 +18,7 @@ project.dependencies { // }else if(isBaiLing()){ // implementation project.project(':OCH:offline:driver') // implementation project.project(':OCH:shuttle:driver_weaknet') +// implementation project.project(':OCH:shuttle:driver_unmanned') // implementation project.project(':OCH:shuttle:passenger_weaknet') // implementation project.project(':OCH:charter:driver') // implementation project.project(':OCH:charter:passenger') @@ -26,6 +28,7 @@ project.dependencies { }else { implementation project.project(':OCH:offline:driver') implementation project.project(':OCH:shuttle:driver_weaknet') + implementation project.project(':OCH:shuttle:driver_unmanned') implementation project.project(':OCH:shuttle:passenger_weaknet') implementation project.project(':OCH:charter:driver') implementation project.project(':OCH:charter:passenger') diff --git a/OCH/facade/src/main/java/com/mogo/och/facade/route/FacadeProvider.kt b/OCH/facade/src/main/java/com/mogo/och/facade/route/FacadeProvider.kt index caff3f2156..e220d370bd 100644 --- a/OCH/facade/src/main/java/com/mogo/och/facade/route/FacadeProvider.kt +++ b/OCH/facade/src/main/java/com/mogo/och/facade/route/FacadeProvider.kt @@ -117,7 +117,12 @@ abstract class FacadeProvider : IMoGoFunctionProvider, ILoginCallback { ||AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode) ||AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { - return getFragmentByServeName(OchCommonConst.SHUTTLE_DRIVER_WEAKNET) + return getFragmentByServeName(if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) { + OchCommonConst.SHUTTLE_DRIVER_UNMANNED + } else { + OchCommonConst.SHUTTLE_DRIVER_WEAKNET + }) +// return getFragmentByServeName(OchCommonConst.SHUTTLE_DRIVER_WEAKNET) }else if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)){ return getFragmentByServeName(OchCommonConst.SHUTTLE_PASSENGER_WEAKNET) } @@ -211,8 +216,12 @@ abstract class FacadeProvider : IMoGoFunctionProvider, ILoginCallback { } statusBarView.tag = "status_bar" val statusBarLP = FrameLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - AutoSizeUtils.dp2px(it, 67.0f), + ViewGroup.LayoutParams.MATCH_PARENT, + if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) { + AutoSizeUtils.dp2px(it, 108.0f) + } else { + AutoSizeUtils.dp2px(it, 67.0f) + }, ) statusBarLP.topMargin = 0 statusBarLP.gravity = Gravity.TOP diff --git a/OCH/shuttle/driver_unmanned/.gitignore b/OCH/shuttle/driver_unmanned/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/OCH/shuttle/driver_unmanned/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/build.gradle b/OCH/shuttle/driver_unmanned/build.gradle new file mode 100644 index 0000000000..a2a12958b8 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/build.gradle @@ -0,0 +1,79 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-kapt' + +android { + compileSdkVersion rootProject.ext.android.compileSdkVersion + // buildToolsVersion rootProject.ext.android.buildToolsVersion + defaultConfig { + minSdkVersion rootProject.ext.android.minSdkVersion + targetSdkVersion rootProject.ext.android.targetSdkVersion + versionCode Integer.valueOf(VERSION_CODE) + versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION") + + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + + kapt { + useBuildCache = false + arguments { + arg("AROUTER_MODULE_NAME", "shuttle_unmanned_"+project.getName()) + arg("room.schemaLocation", "$projectDir/schemas".toString()) + } + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + lintOptions { + abortOnError false + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + debug { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation project(':OCH:common:bridge') + + testImplementation 'junit:junit:4.12' + + implementation rootProject.ext.dependencies.kotlinstdlib + implementation rootProject.ext.dependencies.androidxappcompat + implementation rootProject.ext.dependencies.arouter + kapt rootProject.ext.dependencies.aroutercompiler + implementation rootProject.ext.dependencies.androidxconstraintlayout + implementation rootProject.ext.dependencies.amapnavi3dmap + + implementation rootProject.ext.dependencies.rxjava + implementation rootProject.ext.dependencies.rxandroid + implementation rootProject.ext.dependencies.androidxrecyclerview + kapt rootProject.ext.dependencies.recyclerviewadapterhelper + + implementation rootProject.ext.dependencies.roomRxjava + implementation rootProject.ext.dependencies.androidxroomruntime + kapt rootProject.ext.dependencies.androidxroomcompiler + + + implementation project(":OCH:common:common") + implementation project(":OCH:common:data") + compileOnly project(":libraries:mogo-map") + +} + +apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/consumer-rules.pro b/OCH/shuttle/driver_unmanned/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/OCH/shuttle/driver_unmanned/gradle.properties b/OCH/shuttle/driver_unmanned/gradle.properties new file mode 100644 index 0000000000..dd5c44ee62 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/gradle.properties @@ -0,0 +1,3 @@ +GROUP=com.mogo.och +POM_ARTIFACT_ID=och-bus +VERSION_CODE=1 diff --git a/OCH/shuttle/driver_unmanned/proguard-rules.pro b/OCH/shuttle/driver_unmanned/proguard-rules.pro new file mode 100644 index 0000000000..481bb43481 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/2.json b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/2.json new file mode 100644 index 0000000000..6970eca09c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/2.json @@ -0,0 +1,589 @@ +{ + "formatVersion": 1, + "database": { + "version": 2, + "identityHash": "2b20934a560960930f10ae5c581cbcec", + "entities": [ + { + "tableName": "contrail_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "csvFileUrl", + "columnName": "csv_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "csvFileMd5", + "columnName": "csv_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileUrl", + "columnName": "txt_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileMd5", + "columnName": "txt_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "contrailSaveTime", + "columnName": "contrail_save_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_contrail_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + }, + { + "name": "index_contrail_data_table_md5", + "unique": false, + "columnNames": [ + "md5" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "line_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endStationName", + "columnName": "end_station_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "linegetTime", + "columnName": "line_get_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_line_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "site_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "videoListDB", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_site_data_table_site_id", + "unique": false, + "columnNames": [ + "site_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_site_id` ON `${TABLE_NAME}` (`site_id`)" + }, + { + "name": "index_site_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `task_data` INTEGER, `task_start_time` INTEGER, `start_time` INTEGER, `end_time` INTEGER, `task_get_time` INTEGER NOT NULL, `status` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_data", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "startTime", + "columnName": "start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "endtime", + "columnName": "end_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskgetTime", + "columnName": "task_get_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_task_data_table_task_id", + "unique": false, + "columnNames": [ + "task_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_task_id` ON `${TABLE_NAME}` (`task_id`)" + }, + { + "name": "index_task_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "used_task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "drivingStatus", + "columnName": "driving_status", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaving", + "columnName": "leaving", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "arrivedTime", + "columnName": "arrived_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaveTime", + "columnName": "leave_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "videoList", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "event_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `lineId` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eventType", + "columnName": "event_type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "lineId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "lineName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "writeVersion", + "columnName": "write_version", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_event_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_event_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + } + ], + "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, '2b20934a560960930f10ae5c581cbcec')" + ] + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/3.json b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/3.json new file mode 100644 index 0000000000..f1d18c8322 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/3.json @@ -0,0 +1,589 @@ +{ + "formatVersion": 1, + "database": { + "version": 3, + "identityHash": "2b20934a560960930f10ae5c581cbcec", + "entities": [ + { + "tableName": "contrail_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "csvFileUrl", + "columnName": "csv_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "csvFileMd5", + "columnName": "csv_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileUrl", + "columnName": "txt_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileMd5", + "columnName": "txt_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "contrailSaveTime", + "columnName": "contrail_save_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_contrail_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + }, + { + "name": "index_contrail_data_table_md5", + "unique": false, + "columnNames": [ + "md5" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "line_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endStationName", + "columnName": "end_station_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "linegetTime", + "columnName": "line_get_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_line_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "site_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "videoListDB", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_site_data_table_site_id", + "unique": false, + "columnNames": [ + "site_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_site_id` ON `${TABLE_NAME}` (`site_id`)" + }, + { + "name": "index_site_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `task_data` INTEGER, `task_start_time` INTEGER, `start_time` INTEGER, `end_time` INTEGER, `task_get_time` INTEGER NOT NULL, `status` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_data", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "startTime", + "columnName": "start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "endtime", + "columnName": "end_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskgetTime", + "columnName": "task_get_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_task_data_table_task_id", + "unique": false, + "columnNames": [ + "task_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_task_id` ON `${TABLE_NAME}` (`task_id`)" + }, + { + "name": "index_task_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "used_task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "drivingStatus", + "columnName": "driving_status", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaving", + "columnName": "leaving", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "arrivedTime", + "columnName": "arrived_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaveTime", + "columnName": "leave_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "videoList", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "event_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `lineId` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eventType", + "columnName": "event_type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "lineId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "lineName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "writeVersion", + "columnName": "write_version", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_event_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_event_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + } + ], + "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, '2b20934a560960930f10ae5c581cbcec')" + ] + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/4.json b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/4.json new file mode 100644 index 0000000000..83d629ad24 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/4.json @@ -0,0 +1,601 @@ +{ + "formatVersion": 1, + "database": { + "version": 4, + "identityHash": "1d1bd5c3b1770e4bc24252f26791f036", + "entities": [ + { + "tableName": "contrail_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "csvFileUrl", + "columnName": "csv_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "csvFileMd5", + "columnName": "csv_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileUrl", + "columnName": "txt_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileMd5", + "columnName": "txt_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "contrailSaveTime", + "columnName": "contrail_save_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_contrail_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + }, + { + "name": "index_contrail_data_table_md5", + "unique": false, + "columnNames": [ + "md5" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "line_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endStationName", + "columnName": "end_station_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "linegetTime", + "columnName": "line_get_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_line_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "site_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "videoListDB", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_site_data_table_site_id", + "unique": false, + "columnNames": [ + "site_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_site_id` ON `${TABLE_NAME}` (`site_id`)" + }, + { + "name": "index_site_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `task_data` INTEGER, `task_start_time` INTEGER, `start_time` INTEGER, `end_time` INTEGER, `task_get_time` INTEGER NOT NULL, `status` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_data", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "startTime", + "columnName": "start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "endtime", + "columnName": "end_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskgetTime", + "columnName": "task_get_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_task_data_table_task_id", + "unique": false, + "columnNames": [ + "task_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_task_id` ON `${TABLE_NAME}` (`task_id`)" + }, + { + "name": "index_task_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "used_task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "drivingStatus", + "columnName": "driving_status", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaving", + "columnName": "leaving", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "arrivedTime", + "columnName": "arrived_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaveTime", + "columnName": "leave_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "videoList", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "event_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `lineId` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `msg_id` TEXT, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eventType", + "columnName": "event_type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "lineId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "lineName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "writeVersion", + "columnName": "write_version", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "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, '1d1bd5c3b1770e4bc24252f26791f036')" + ] + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/5.json b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/5.json new file mode 100644 index 0000000000..bdeee2552a --- /dev/null +++ b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/5.json @@ -0,0 +1,739 @@ +{ + "formatVersion": 1, + "database": { + "version": 5, + "identityHash": "018ed967c5f335de5d39581e033160ed", + "entities": [ + { + "tableName": "contrail_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "csvFileUrl", + "columnName": "csv_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "csvFileMd5", + "columnName": "csv_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileUrl", + "columnName": "txt_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileMd5", + "columnName": "txt_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "contrailSaveTime", + "columnName": "contrail_save_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_contrail_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + }, + { + "name": "index_contrail_data_table_md5", + "unique": false, + "columnNames": [ + "md5" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "line_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endStationName", + "columnName": "end_station_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "linegetTime", + "columnName": "line_get_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_line_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "site_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "videoListDB", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_site_data_table_site_id", + "unique": false, + "columnNames": [ + "site_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_site_id` ON `${TABLE_NAME}` (`site_id`)" + }, + { + "name": "index_site_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `task_data` INTEGER, `task_start_time` INTEGER, `start_time` INTEGER, `end_time` INTEGER, `task_get_time` INTEGER NOT NULL, `status` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_data", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "startTime", + "columnName": "start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "endtime", + "columnName": "end_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskgetTime", + "columnName": "task_get_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "status", + "columnName": "status", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_task_data_table_task_id", + "unique": false, + "columnNames": [ + "task_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_task_id` ON `${TABLE_NAME}` (`task_id`)" + }, + { + "name": "index_task_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_task_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "used_task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "drivingStatus", + "columnName": "driving_status", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaving", + "columnName": "leaving", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "arrivedTime", + "columnName": "arrived_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaveTime", + "columnName": "leave_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "videoList", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "event_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `lineId` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `msg_id` TEXT, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eventType", + "columnName": "event_type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "lineId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "lineName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "writeVersion", + "columnName": "write_version", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_event_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_event_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "writeoff_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `msg_id` TEXT, `expiry_time` INTEGER, `booking_time` INTEGER, `type` INTEGER, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `driver_id` INTEGER, `available_times` INTEGER, `order_no` TEXT, `uid` TEXT, `seq` TEXT, `business_time` INTEGER, `tick_size` INTEGER, `tick_name` TEXT, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "expiryTime", + "columnName": "expiry_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bookingTime", + "columnName": "booking_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "availableTimes", + "columnName": "available_times", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "orderNo", + "columnName": "order_no", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "uid", + "columnName": "uid", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "phone", + "columnName": "seq", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketSize", + "columnName": "tick_size", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketName", + "columnName": "tick_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_writeoff_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_writeoff_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '018ed967c5f335de5d39581e033160ed')" + ] + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/6.json b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/6.json new file mode 100644 index 0000000000..68154b9555 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/6.json @@ -0,0 +1,775 @@ +{ + "formatVersion": 1, + "database": { + "version": 6, + "identityHash": "a2451ba8fe1fb6312258d93e3c2c2c8c", + "entities": [ + { + "tableName": "contrail_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "csvFileUrl", + "columnName": "csv_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "csvFileMd5", + "columnName": "csv_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileUrl", + "columnName": "txt_file_url", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "txtFileMd5", + "columnName": "txt_file_md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "contrailSaveTime", + "columnName": "contrail_save_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_contrail_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + }, + { + "name": "index_contrail_data_table_md5", + "unique": false, + "columnNames": [ + "md5" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "line_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endStationName", + "columnName": "end_station_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "linegetTime", + "columnName": "line_get_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_line_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "site_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "videoListDB", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_site_data_table_site_id", + "unique": false, + "columnNames": [ + "site_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_site_id` ON `${TABLE_NAME}` (`site_id`)" + }, + { + "name": "index_site_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_site_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "task_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `shifts_id` INTEGER, `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": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "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, `shifts_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "drivingStatus", + "columnName": "driving_status", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaving", + "columnName": "leaving", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "arrivedTime", + "columnName": "arrived_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaveTime", + "columnName": "leave_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "videoList", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "event_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `shifts_id` INTEGER, `lineId` INTEGER, `task_date` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `msg_id` TEXT, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eventType", + "columnName": "event_type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "lineId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_date", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "lineName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "writeVersion", + "columnName": "write_version", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_event_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_event_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "writeoff_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `msg_id` TEXT, `expiry_time` INTEGER, `booking_time` INTEGER, `type` INTEGER, `shifts_id` INTEGER, `task_id` INTEGER, `task_date` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `driver_id` INTEGER, `available_times` INTEGER, `order_no` TEXT, `uid` TEXT, `seq` TEXT, `business_time` INTEGER, `tick_size` INTEGER, `tick_name` TEXT, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "expiryTime", + "columnName": "expiry_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bookingTime", + "columnName": "booking_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_date", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "availableTimes", + "columnName": "available_times", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "orderNo", + "columnName": "order_no", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "uid", + "columnName": "uid", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "phone", + "columnName": "seq", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketSize", + "columnName": "tick_size", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketName", + "columnName": "tick_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_writeoff_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_writeoff_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a2451ba8fe1fb6312258d93e3c2c2c8c')" + ] + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/7.json b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/7.json new file mode 100644 index 0000000000..39d39f6f62 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/7.json @@ -0,0 +1,861 @@ +{ + "formatVersion": 1, + "database": { + "version": 7, + "identityHash": "74e6f2a37be355d3c235b4a0b837cf5d", + "entities": [ + { + "tableName": "contrail_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `contrail_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT, `source` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "contrailId", + "columnName": "contrail_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 + }, + { + "fieldPath": "source", + "columnName": "source", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_contrail_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + }, + { + "name": "index_contrail_data_table_md5", + "unique": false, + "columnNames": [ + "md5" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "line_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endStationName", + "columnName": "end_station_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "linegetTime", + "columnName": "line_get_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_line_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "site_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "videoListDB", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "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, `shifts_id` INTEGER, `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": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "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": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "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, `shifts_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "drivingStatus", + "columnName": "driving_status", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaving", + "columnName": "leaving", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "arrivedTime", + "columnName": "arrived_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaveTime", + "columnName": "leave_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "videoList", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "event_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `shifts_id` INTEGER, `lineId` INTEGER, `task_date` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `msg_id` TEXT, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eventType", + "columnName": "event_type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "lineId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_date", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "lineName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "writeVersion", + "columnName": "write_version", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_event_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_event_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "writeoff_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `msg_id` TEXT, `expiry_time` INTEGER, `booking_time` INTEGER, `type` INTEGER, `shifts_id` INTEGER, `task_id` INTEGER, `task_date` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `driver_id` INTEGER, `available_times` INTEGER, `order_no` TEXT, `uid` TEXT, `seq` TEXT, `business_time` INTEGER, `tick_size` INTEGER, `tick_name` TEXT, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "expiryTime", + "columnName": "expiry_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bookingTime", + "columnName": "booking_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_date", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "availableTimes", + "columnName": "available_times", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "orderNo", + "columnName": "order_no", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "uid", + "columnName": "uid", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "phone", + "columnName": "seq", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketSize", + "columnName": "tick_size", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketName", + "columnName": "tick_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_writeoff_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_writeoff_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "point_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `contrail_id` INTEGER, `site_id` INTEGER, `md5` TEXT, `seq` INTEGER, `point_type` INTEGER, `longitude` REAL, `latitude` REAL, `sub_seq` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "contrailId", + "columnName": "contrail_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pointType", + "columnName": "point_type", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "longitude", + "columnName": "longitude", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "latitude", + "columnName": "latitude", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "subSeq", + "columnName": "sub_seq", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "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, '74e6f2a37be355d3c235b4a0b837cf5d')" + ] + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/8.json b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/8.json new file mode 100644 index 0000000000..e7a0f0b2ba --- /dev/null +++ b/OCH/shuttle/driver_unmanned/schemas/com.mogo.och.unmanned.repository.db.MyDataBase/8.json @@ -0,0 +1,875 @@ +{ + "formatVersion": 1, + "database": { + "version": 8, + "identityHash": "761be9c0c9726513939d5788d36c9c1d", + "entities": [ + { + "tableName": "contrail_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `contrail_id` INTEGER, `csv_file_url` TEXT, `csv_file_md5` TEXT, `txt_file_url` TEXT, `txt_file_md5` TEXT, `contrail_save_time` INTEGER, `md5` TEXT, `source` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "contrailId", + "columnName": "contrail_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 + }, + { + "fieldPath": "source", + "columnName": "source", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_contrail_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + }, + { + "name": "index_contrail_data_table_md5", + "unique": false, + "columnNames": [ + "md5" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_contrail_data_table_md5` ON `${TABLE_NAME}` (`md5`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "line_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `line_name` TEXT, `end_station_name` TEXT, `line_get_time` INTEGER NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "endStationName", + "columnName": "end_station_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "linegetTime", + "columnName": "line_get_time", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_line_data_table_line_id", + "unique": false, + "columnNames": [ + "line_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_line_data_table_line_id` ON `${TABLE_NAME}` (`line_id`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "site_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `site_id` INTEGER, `line_id` INTEGER, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `introduction` TEXT, `is_play_tts` INTEGER, `md5` TEXT, `videoList` TEXT, `tag` INTEGER NOT NULL DEFAULT 0)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "videoListDB", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "tag", + "columnName": "tag", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "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, `shifts_id` INTEGER, `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": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "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": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "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, `shifts_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `line_name` TEXT, `name` TEXT, `name_kr` TEXT, `seq` INTEGER, `gcj_lon` REAL, `gcj_lat` REAL, `lon` REAL, `lat` REAL, `driving_status` INTEGER, `leaving` INTEGER, `arrived_time` INTEGER, `leave_time` INTEGER, `introduction` TEXT, `is_play_tts` INTEGER, `event_save_time` INTEGER NOT NULL, `videoList` TEXT, `tag` INTEGER NOT NULL DEFAULT 0)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "line_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "nameKr", + "columnName": "name_kr", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "gcjLon", + "columnName": "gcj_lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "gcjLat", + "columnName": "gcj_lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lon", + "columnName": "lon", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "lat", + "columnName": "lat", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "drivingStatus", + "columnName": "driving_status", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaving", + "columnName": "leaving", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "arrivedTime", + "columnName": "arrived_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "leaveTime", + "columnName": "leave_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "introduction", + "columnName": "introduction", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isPlayTts", + "columnName": "is_play_tts", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "videoList", + "columnName": "videoList", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "tag", + "columnName": "tag", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "event_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `event_type` TEXT, `shifts_id` INTEGER, `lineId` INTEGER, `task_date` INTEGER, `lineName` TEXT, `task_id` INTEGER, `task_start_time` INTEGER, `business_time` INTEGER, `write_version` INTEGER, `site_id` INTEGER, `seq` INTEGER, `driver_id` INTEGER, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `msg_id` TEXT, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "eventType", + "columnName": "event_type", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "lineId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_date", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineName", + "columnName": "lineName", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskStartTime", + "columnName": "task_start_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "writeVersion", + "columnName": "write_version", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_event_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_event_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "writeoff_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `msg_id` TEXT, `expiry_time` INTEGER, `booking_time` INTEGER, `type` INTEGER, `shifts_id` INTEGER, `task_id` INTEGER, `task_date` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `driver_id` INTEGER, `available_times` INTEGER, `order_no` TEXT, `uid` TEXT, `seq` TEXT, `business_time` INTEGER, `tick_size` INTEGER, `tick_name` TEXT, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `update_time` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "msgId", + "columnName": "msg_id", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "expiryTime", + "columnName": "expiry_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bookingTime", + "columnName": "booking_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "shiftsId", + "columnName": "shifts_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskId", + "columnName": "task_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "taskDate", + "columnName": "task_date", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "driverId", + "columnName": "driver_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "availableTimes", + "columnName": "available_times", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "orderNo", + "columnName": "order_no", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "uid", + "columnName": "uid", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "phone", + "columnName": "seq", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "businessTime", + "columnName": "business_time", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketSize", + "columnName": "tick_size", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "ticketName", + "columnName": "tick_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "eventSaveTime", + "columnName": "event_save_time", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "updateStatus", + "columnName": "update_status", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "upDateTime", + "columnName": "update_time", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [ + { + "name": "index_writeoff_data_table_event_save_time", + "unique": false, + "columnNames": [ + "event_save_time" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_writeoff_data_table_event_save_time` ON `${TABLE_NAME}` (`event_save_time`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "point_data_table", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `contrail_id` INTEGER, `site_id` INTEGER, `md5` TEXT, `seq` INTEGER, `point_type` INTEGER, `longitude` REAL, `latitude` REAL, `sub_seq` INTEGER)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "lineId", + "columnName": "line_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "contrailId", + "columnName": "contrail_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "siteId", + "columnName": "site_id", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "md5", + "columnName": "md5", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "seq", + "columnName": "seq", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "pointType", + "columnName": "point_type", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "longitude", + "columnName": "longitude", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "latitude", + "columnName": "latitude", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "subSeq", + "columnName": "sub_seq", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "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, '761be9c0c9726513939d5788d36c9c1d')" + ] + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/AndroidManifest.xml b/OCH/shuttle/driver_unmanned/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..91145d858f --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ShuttleDriverUnmannedProvider.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ShuttleDriverUnmannedProvider.kt new file mode 100644 index 0000000000..56e5d4c949 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ShuttleDriverUnmannedProvider.kt @@ -0,0 +1,90 @@ +package com.mogo.och.unmanned + +import android.content.Context +import android.view.View +import androidx.fragment.app.Fragment +import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.bridge.autopilot.autopilot.OchAutopilotAnalytics +import com.mogo.och.bridge.ui.autopilot.AutopilotState +import com.mogo.och.common.module.biz.provider.CommonServiceImpl +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.repository.EventDb +import com.mogo.och.unmanned.repository.db.repository.LineDb +import com.mogo.och.unmanned.repository.db.repository.TaskDb +import com.mogo.och.unmanned.repository.db.repository.TaskSiteDb +import com.mogo.och.unmanned.repository.db.repository.WriteOffDb +import com.mogo.och.unmanned.ui.fragment.ShuttleFragment +import com.mogo.och.unmanned.ui.qr.QrOpenView +import com.mogo.och.unmanned.util.BusAnalyticsManager +import com.mogo.och.unmanned.util.BusTrajectoryManager + +/** + * 网约车小巴业务实现入口 + * + * @author tongchenfei + */ +@Route(path = OchCommonConst.SHUTTLE_DRIVER_UNMANNED) +class ShuttleDriverUnmannedProvider : CommonServiceImpl() { + + private val TAG = M_BUS + ShuttleDriverUnmannedProvider::class.java.simpleName + private var busFragment: ShuttleFragment? = null + + override fun init(context: Context) { + d(TAG, "init") + ThreadUtils.getIoPool().submit { + LineDb.deleteObsoleteData() + TaskDb.deleteObsoleteData() + TaskSiteDb.deleteObsoleteData() + EventDb.deleteObsoleteData() + WriteOffDb.deleteObsoleteData() + } + } + + override fun getFragment(): Fragment { + d(TAG, "getFragment") + if (busFragment == null) { + busFragment = ShuttleFragment() + } + OchAutopilotAnalytics.ochEventKey = BusAnalyticsManager + LineModel.init() +// ScannerManager.load() + BusTrajectoryManager.load() + return busFragment!! + } + + override fun resetFragment() { + d(TAG, "resetFragment") + busFragment = null + OchAutopilotAnalytics.ochEventKey = null + LineModel.release() +// ScannerManager.release() + BusTrajectoryManager.release() + RepositoryManager.release() + } + + override fun createOchBusinessView(context: Context?): View? { + d(TAG, "createOchBusinessView") + return null + } + + override fun createOchBindQRCodeView(context: Context?): View? { + if (FunctionBuildConfig.urlJson.bindDriverQRUrl.isNullOrEmpty()) { + return null + } + return context?.let { + QrOpenView(it) + } + } + + override fun createStartAutopilotView(context: Context?): View? { + return context?.let { + AutopilotState(it) + } + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/action/TaskUsedAction.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/action/TaskUsedAction.kt new file mode 100644 index 0000000000..d6a8792424 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/action/TaskUsedAction.kt @@ -0,0 +1,30 @@ +package com.mogo.och.unmanned.action + +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.common.module.manager.socket.cloud.IOchOnMessageListener +import com.mogo.och.common.module.manager.socket.cloud.data.TaskUsedMsg +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.repository.RepositoryManager + +class TaskUsedAction() : + IOchOnMessageListener { + + private val tag = M_BUS + "OperateAction" + + override fun target(): Class { + + return TaskUsedMsg::class.java + } + + override fun onMsgReceived(obj: TaskUsedMsg?) { + i(tag, "onMsgReceived = $obj") + obj?.apply { + if (LoginStatusManager.getOchBizInfo()?.businessType == businessType + && RepositoryManager.supportDb()) { + LineModel.endTaskByOther(taskId, plateNumber) + } + } + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/WaitUploadTask.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/WaitUploadTask.kt new file mode 100644 index 0000000000..5ed45537bc --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/WaitUploadTask.kt @@ -0,0 +1,36 @@ +package com.mogo.och.unmanned.bean + +data class WaitUploadLine(var lineName: String, var lineId: Long, var task: MutableList) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as WaitUploadLine + + if (lineId != other.lineId) return false + if (task != other.task) return false + + return true + } + + override fun hashCode(): Int { + var result = lineId.hashCode() + result = 31 * result + task.hashCode() + return result + } +} + +data class WaitUploadTask(val taskStartTime: Long, val taskId: Long, val waitUploadWriteOff: Int) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as WaitUploadTask + + return taskId == other.taskId + } + + override fun hashCode(): Int { + return taskId.hashCode() + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/WriteOffPassenger.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/WriteOffPassenger.java new file mode 100644 index 0000000000..6240711bbe --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/WriteOffPassenger.java @@ -0,0 +1,26 @@ +package com.mogo.och.unmanned.bean; + +import java.io.Serializable; + +/** + * @author: wangmingjun + * @date: 2022/9/23 + */ +public class WriteOffPassenger implements Serializable { + public String phone; + public String orderNo; + public String ticketName; + public int passengerSize; + public long writeOffTime; + + @Override + public String toString() { + return "WriteOffPassenger{" + + "phone='" + phone + '\'' + + ", orderNo='" + orderNo + '\'' + + ", ticketName='" + ticketName + '\'' + + ", passengerSize=" + passengerSize + + ", writeOffTime=" + writeOffTime + + '}'; + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/BusQueryLineStationsRequest.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/BusQueryLineStationsRequest.java new file mode 100644 index 0000000000..180891e70d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/BusQueryLineStationsRequest.java @@ -0,0 +1,18 @@ +package com.mogo.och.unmanned.bean.request; + +import com.mogo.commons.storage.SharedPrefsMgr; + +/** + * @author congtaowang + * @since 2021/3/22 + *

+ * 根据车机行驶线路站点信息 + */ +public class BusQueryLineStationsRequest { + + private String sn; + + public BusQueryLineStationsRequest() { + this.sn = SharedPrefsMgr.getInstance().getSn(); + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/QueryPointRequest.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/QueryPointRequest.kt new file mode 100644 index 0000000000..51c329f9b2 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/QueryPointRequest.kt @@ -0,0 +1,10 @@ +package com.mogo.och.unmanned.bean.request + +/** + * 通过lineid 获取轨迹id + */ +data class QueryPointRequest(val businessType: Int, val lineIds: MutableList) { + companion object { + + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/ShuttleEventRequest.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/ShuttleEventRequest.kt new file mode 100644 index 0000000000..32f180d042 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/request/ShuttleEventRequest.kt @@ -0,0 +1,83 @@ +package com.mogo.och.unmanned.bean.request + +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.network.utils.digest.DigestUtils +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.och.bridge.device.checkvin.CheckVinManager +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.unmanned.repository.db.bean.EventDataBean +import com.mogo.och.unmanned.repository.db.bean.WriteOffDataBean + +/** + * 上报事件 + */ +data class ShuttleEventRequest(val requestId: String, val sn: String, val vin: String, val businessType: Int, val eventList: MutableList) { + companion object { + fun transformDb2Net( + waitUpdateEvent: List?, + waitUpdateWriteOffEvent: List? + ): ShuttleEventRequest { + val businessTypeShuttle = LoginStatusManager.getOchBizInfo()?.businessType ?: 11 + val eventList4Request = mutableListOf() + var tempEvent: Event? = null + waitUpdateEvent?.forEach { + tempEvent = if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + Event(it.eventType, + EventData(0, it.taskId, it.taskDate, it.businessTime, it.writeVersion, it.siteId, it.seq, it.driverId, it.msgId) + ) + } else { + Event(it.eventType, + EventData(it.taskId, 0, it.taskDate, it.businessTime, it.writeVersion, it.siteId, it.seq, it.driverId, it.msgId) + ) + } + eventList4Request.add(tempEvent!!) + } + + waitUpdateWriteOffEvent?.forEach { + tempEvent = if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + Event("WriteOff", + WriteOffEventData(it.msgId, 0, it.taskId, it.taskDate, it.siteId, it.driverId, it.orderNo, it.businessTime, it.businessTime) + ) + } else { + Event("WriteOff", + WriteOffEventData(it.msgId, it.taskId, 0, 0, it.siteId, it.driverId, it.orderNo, it.businessTime, it.businessTime) + ) + } + eventList4Request.add(tempEvent!!) + } + eventList4Request.sortBy { it.eventData.businessTime } + val md5Hex = DigestUtils.md5Hex(eventList4Request.toString()) + return ShuttleEventRequest(md5Hex, SharedPrefsMgr.getInstance().sn, CheckVinManager.getVin(), + businessTypeShuttle, eventList4Request) + } + } +} + +data class Event(var eventType: String?, val eventData: EventDataBase) + +open class EventDataBase(val msgtype: String, var businessTime: Long?) + +data class EventData( + var taskId: Long?, + var shiftsId: Long?, + var taskDate: Long?, + var businessTimeout: Long?, + var writeVersion: Long?, + var siteId: Long?, + var seq: Int?, + var driverId: Long?, + var msgId: String? +) : EventDataBase(msgtype = "lineEvent", businessTime = businessTimeout) + +data class WriteOffEventData( + var msgId: String?, + var taskId: Long?, + var shiftsId: Long?, + var taskDate: Long?, + var siteId: Long?, + var driverId: Long?, + var orderNo: String?, + var businessTimeout: Long?, + var writeVersion: Long?, +) : EventDataBase(msgtype = "writeoffEvent", businessTime = businessTimeout) \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/BusRoutesResponse.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/BusRoutesResponse.kt new file mode 100644 index 0000000000..86f891556b --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/BusRoutesResponse.kt @@ -0,0 +1,157 @@ +package com.mogo.och.unmanned.bean.response + +import com.google.gson.reflect.TypeToken +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.data.bean.BusStationBean +import com.mogo.och.data.bean.LineInfo +import com.mogo.och.data.bean.SiteIntroduce +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.repository.db.bean.PointDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean +import com.mogo.och.unmanned.repository.db.repository.PointDb +import com.mogo.och.unmanned.repository.db.repository.TaskSiteDb +import java.lang.Boolean +import kotlin.Exception +import kotlin.Int +import kotlin.Long +import kotlin.Pair +import kotlin.String +import kotlin.let +import kotlin.toString + +/** + * 网约车小巴路线接口请求响应结果 + * + * @author tongchenfei + */ +class BusRoutesResponse : BaseData() { + var data: BusRoutesResult? = null + + override fun toString(): String { + return "BusRoutesResponse{" + + "data=" + data + + '}' + } + + companion object { + + fun db2Beans(runnintTaskAndSites: List?, lineId: Long?): Pair, Int> { + val result = mutableListOf() + var temp: BusStationBean? = null + var currentStationIndex = -1 + var lineInfo: LineInfo? = null + if (runnintTaskAndSites.isNullOrEmpty()) { + LineManager.setLineInfo(lineInfo) + return Pair(result, currentStationIndex) + } + val points = PointDb.queryPointByLineId(lineId) + runnintTaskAndSites.forEachIndexed { index, taskAndsite -> + temp = BusStationBean() + temp?.drivingStatus = (taskAndsite.drivingStatus ?: 0) + temp?.lat = (taskAndsite.lat ?: 0.0) + temp?.lon = (taskAndsite.lon ?: 0.0) + temp?.gcjLat = (taskAndsite.gcjLat ?: 0.0) + temp?.gcjLon = (taskAndsite.gcjLon ?: 0.0) + temp?.introduction = taskAndsite.introduction + temp?.isLeaving = Boolean.TRUE == taskAndsite.leaving + temp?.name = taskAndsite.name + temp?.nameKr = taskAndsite.nameKr + temp?.isPlayTts = Boolean.TRUE == taskAndsite.isPlayTts + temp?.seq = (taskAndsite.seq ?: 0) + temp?.tag = taskAndsite.tag + temp?.siteId = if (taskAndsite.siteId == null) 0 else taskAndsite.siteId!!.toInt() + points?.let { pointList -> + val sitePoint = pointList.filter { + it.siteId?.toInt() == temp?.siteId + }.sortedWith( + compareBy { it.subSeq } +// .thenBy {it.subSeq } + ) + val tempPassPoints = mutableListOf() + val tempblackPoints = mutableListOf() + sitePoint.forEach { point -> + when (point.pointType) { + PointDataBean.pointTypePass -> { + tempPassPoints.add(point.toStation()) + } + + PointDataBean.pointTypeBlack -> { + tempblackPoints.add(point.toStation()) + } + + else -> {} + } + } + temp?.passPoints = tempPassPoints + temp?.blackPoints = tempblackPoints + } + + if (!taskAndsite.videoList.isNullOrEmpty()) { + try { + val list = GsonUtils.fromJson>( + taskAndsite.videoList, + object : TypeToken?>() {}.type + ) + temp?.videoList = list.toMutableList() + } catch (e: Exception) { + temp?.videoList = null + } + + } + result.add(temp!!) + // 正在进行中的任务 + if (temp!!.drivingStatus == TaskSiteDataBean.drivingStatusCurrent) { + if (temp!!.tag != 2) { + currentStationIndex = index + } + } + // 线路信息 + if (lineInfo == null && taskAndsite.lineId != null && taskAndsite.lineName != null) { + lineInfo = LineInfo(taskAndsite.lineId!!, taskAndsite.lineName!!, orderId = taskAndsite.taskId.toString()) + } + } + if (currentStationIndex == -1) { + val pos = result.indexOfFirst { it.tag != 2 } + currentStationIndex = if (pos != -1) { + pos + } else { + 0 + } + } + lineInfo?.multiMap?.put("taskInfo", LineModel.getTaskTime()) + lineInfo?.siteInfos = result + LineManager.setLineInfo(lineInfo) + + return Pair(result, currentStationIndex) + } + + fun bean2Db(sites: MutableList, lineId: Long, lineName: String?, taskId: Long) { + val runnintTaskAndSites = mutableListOf() + sites.forEach { + val temp = TaskSiteDataBean() + temp.taskId = taskId + temp.lineId = lineId + temp.siteId = it.siteId.toLong() + temp.lineName = lineName + temp.name = it.name + temp.nameKr = it.nameKr + temp.seq = it.seq + temp.gcjLat = it.gcjLat + temp.gcjLon = it.gcjLon + temp.lon = it.lon + temp.lat = it.lat + temp.drivingStatus = it.drivingStatus + temp.leaving = it.isLeaving + temp.introduction = it.introduction + temp.isPlayTts = it.isPlayTts + temp.videoList = GsonUtils.toJson(it.videoList) + runnintTaskAndSites.add(temp) + } + TaskSiteDb.addOrUpdate(*runnintTaskAndSites.toTypedArray()) + } + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/CarExecutableTaskResponse.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/CarExecutableTaskResponse.kt new file mode 100644 index 0000000000..d686925a11 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/CarExecutableTaskResponse.kt @@ -0,0 +1,105 @@ +package com.mogo.och.unmanned.bean.response + +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.och.data.bean.SiteIntroduce +import com.mogo.och.unmanned.repository.db.bean.ContrailDataBean +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.SiteDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.db.repository.ContraiDb +import com.mogo.och.unmanned.repository.db.repository.LineDb +import com.mogo.och.unmanned.repository.db.repository.SiteDb +import com.mogo.och.unmanned.repository.db.repository.TaskDb + +/** + * + */ +data class CarExecutableTaskResponse(val data: List?) : BaseData() { + + data class Result( + var line: LineDataBeanInsert?, + var siteList: List?,//站点名称 + val contrail: ContrailDataBean?,//站点名称 + val taskList: List?,//站点名称 + ) + + + data class LineDataBeanInsert( + + /** + * 线路id + */ + var lineId: Long? = null, + + /** + * 线路名称 + */ + var lineName: String? = null, + /** + * 终点站点名称 + */ + var endStationName: String? = null, + + ) + + companion object { + /** + * 保存 线路信息、自驾轨迹信息、站点信息和任务到数据库 + */ + fun save2Db(data: CarExecutableTaskResponse) { + val lineList = mutableListOf() + val contrailList = mutableListOf() + val siteList = mutableListOf() + + data.data?.forEach { dataInfo -> + var lineId: Long? = null + dataInfo.line?.let { lineInfo -> + val tempLineInfo = LineDataBean() + lineId = lineInfo.lineId + tempLineInfo.lineId = lineInfo.lineId + tempLineInfo.lineName = lineInfo.lineName + tempLineInfo.endStationName = dataInfo.siteList?.last()?.name ?: "" + lineList.add(tempLineInfo) + } + dataInfo.contrail?.let { contrailInfo -> + contrailInfo.lineId = lineId + contrailList.add(contrailInfo) + } + dataInfo.siteList?.let { siteListInfo -> + siteListInfo.forEach { + it.lineId = lineId + val videoInfoList = mutableListOf() + it.videoList?.forEach { videoInfoIt -> + videoInfoList.add(videoInfoIt) + } + if (videoInfoList.isNotEmpty()) { + it.videoListDB = GsonUtils.toJson(videoInfoList) + } + } + siteList.addAll(siteListInfo) + } + dataInfo.taskList?.let { taskInfs -> + taskInfs.forEach { + it.lineId = lineId + if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + // 班车需要前台生产任务Id 前台规则 任务id 等同模板id + it.taskId = it.shiftsId + } + } + TaskDb.addOrUpdate(taskInfs, lineId) + } + } + + LineDb.checkAndUpdate(lineList) + ContraiDb.addOrUpdate(contrailList) + SiteDb.addOrUpdate(siteList) + + TaskDb.resetShiftsIdDetail() + } + + } +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/PointResponse.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/PointResponse.kt new file mode 100644 index 0000000000..16b757d551 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/PointResponse.kt @@ -0,0 +1,42 @@ +package com.mogo.och.unmanned.bean.response + +import com.mogo.eagle.core.data.BaseData + + +class PointsResponse : BaseData() { + var data: MutableList? = null +} + +data class Point( + val latitude: Double, + val longitude: Double, + val pointType: Int, + val segment: Int +) + +data class Black( + val latitude: Double, + val longitude: Double, + val pointType: Int, + val segment: Int +) + +data class PointResponse( + val businessType: Int, + val contrailId: Long, + val contrailSaveTime: Long, + val csvFileMd5: String, + val csvFileUrl: String, + val lineId: Long, + val lineName: String, + val segmentPointList: List, + val source: Int, + val txtFileMd5: String, + val txtFileUrl: String +) + +data class SegmentPoint( + val blackList: List, + val pointList: List, + val segment: Int? +) \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/WriteOffCountResponse.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/WriteOffCountResponse.java new file mode 100644 index 0000000000..911d32c20b --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/bean/response/WriteOffCountResponse.java @@ -0,0 +1,13 @@ +package com.mogo.och.unmanned.bean.response; + +import com.mogo.eagle.core.data.BaseData; + +/** + * @author: wangmingjun + * @date: 2022/2/9 + */ +public class WriteOffCountResponse extends BaseData { + + public Integer data; + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/callback/IBusLinesCallback.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/callback/IBusLinesCallback.java new file mode 100644 index 0000000000..44a9feb628 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/callback/IBusLinesCallback.java @@ -0,0 +1,41 @@ +package com.mogo.och.unmanned.callback; + +/** + * @author: wangmingjun + * @date: 2022/2/9 + */ +public interface IBusLinesCallback { + + default void onChangeLineIdSuccess() { + } + + default void onRefreshSuccess(long currentTimeStamp) { + } + + default void onRefreshSuccessWIthData() { + } + + default void onChangeLineIdFail() { + } + + default void onNoRunningTask() { + } + + default void onRunningTask() { + } + + default void onLeaveStaionSuccess() { + } + + default void onArriveStationSuccess() { + } + + default void onCompleteTask() { + } + + default void onCompleteTaskFail() { + } + + default void onEndTaskByOther(long taskId, String plateNumber) { + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/constant/BusConst.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/constant/BusConst.kt new file mode 100644 index 0000000000..3b181625d4 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/constant/BusConst.kt @@ -0,0 +1,53 @@ +package com.mogo.och.unmanned.constant + +/** + * Created on 2021/12/6 + */ +class BusConst { + companion object { + + // 测试用的广播 + const val BROADCAST_TEST_BUS_CONTROL_TYPE_EXTRA_KEY = "sceneType" + + // 上报心跳轮询ms + const val LOOP_PERIOD_60S = 60 * 1000L + + // 开始服务启动自动驾驶等待时间(埋点上传) + const val LOOP_PERIOD_15S = 15 * 1000L + const val LOOP_PERIOD_1S = 1 * 1000L + const val LOOP_DELAY = 100L + + // 下发给MEC轨迹信息间隔时间 10秒 + const val LOOP_PERIOD_10S = 10 * 1000L + + // 尝试下发给MEC轨迹最多10次 + const val LOOP_SEND_TRAJ_TIMES = 10 + + const val SEND_OUTVOICE_DISTANCES_TARTSTATIONE = 15 + + // 恢复数据时 等待同步基础数据等待2s + const val waitSysAllData = 2_000L + + // 最多等待5次 + const val waitCount = 5 + + //起点UUID + const val BUS_START_MAP_MAKER = "bus_start_map_maker"; + + //终点UUID + const val BUS_END_MAP_MAKER = "bus_end_map_maker"; + + + /** + * 订单起终点Marker类型 + */ + const val TYPE_MARKER_BUS_ORDER = "TYPE_MARKER_BUS_ORDER" + + const val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L + + //围栏到站 暂定10米 + const val ARRIVE_AT_END_STATION_DISTANCE = 10 + + const val DELAY_10S = 10 * 1000L + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/EventModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/EventModel.kt new file mode 100644 index 0000000000..fd197f030e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/EventModel.kt @@ -0,0 +1,159 @@ +package com.mogo.och.unmanned.model + +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.unmanned.bean.WaitUploadLine +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.bean.EventDataBean +import com.mogo.och.unmanned.repository.db.repository.EventDb +import com.mogo.och.unmanned.repository.db.repository.SiteDb +import com.mogo.och.unmanned.repository.db.repository.WriteOffDb +import io.reactivex.Observable +import io.reactivex.disposables.Disposable +import io.reactivex.subjects.BehaviorSubject +import java.util.concurrent.atomic.AtomicBoolean + +object EventModel { + + private val isUpdating by lazy { AtomicBoolean(false) } + + private val createDefault = BehaviorSubject.createDefault(isUpdating.get()) + + private var eventUpdateInfo: Disposable? = null + + const val TAG = "${M_BUS}EventModel" + + + fun load() { + if (RepositoryManager.supportDb() || RepositoryManager.supportWriteOffDb()) { + RxUtils.disposeSubscribe(eventUpdateInfo) + eventUpdateInfo = RxUtils.createSubscribe(2 * 60 * 1000) { + updateEvent() + } + } + } + + fun release() { + isUpdating.set(false) + RxUtils.disposeSubscribe(eventUpdateInfo) + } + + fun notifySyn() { + RxUtils.disposeSubscribe(eventUpdateInfo) + updateEvent() + checkDbData() + } + + private fun checkDbData() { + BizLoopManager.runInIoThread { + SiteDb.checkData() + } + } + + + private fun updateEvent() { + if (isUpdating.get()) { + d(TAG, "上报event-正在上传 等待下一次轮训 ") + OchChainLogManager.writeChainLogDb("上报event", "正在上传 等待下一次轮训") + return + } + isUpdating.set(true) + createDefault.onNext(isUpdating.get()) + ThreadUtils.getSinglePool().submit { + val waitUpdateLineEvent = EventDb.queryWaitUpdateEvent() + val waitUpdateWriteOffEvent = WriteOffDb.queryWaitUpdateEvent() + if (waitUpdateLineEvent.isNullOrEmpty() && waitUpdateWriteOffEvent.isNullOrEmpty()) { + d(TAG, "上报event-没有数据需要上报 ") + OchChainLogManager.writeChainLogDb("上报event", "没有数据需要上报") + isUpdating.set(false) + createDefault.onNext(isUpdating.get()) + RxUtils.disposeSubscribe(eventUpdateInfo) + eventUpdateInfo = RxUtils.createSubscribe(2 * 60 * 1000) { + updateEvent() + } + return@submit + } + d(TAG, "上报event-开始上报 ") + OchChainLogManager.writeChainLogDb("上报event", "开始上") + val transformDb2Net = ShuttleEventRequest.transformDb2Net(waitUpdateLineEvent, waitUpdateWriteOffEvent) + RepositoryManager.reportCabinEvent(AbsMogoApplication.getApp()!!, transformDb2Net, object : OchCommonServiceCallback { + override fun onSuccess(data: BaseData?) { + d(TAG, "上报event-上报event成功 $transformDb2Net ") + OchChainLogManager.writeChainLogDb("上报event成功", "$transformDb2Net") + + waitUpdateLineEvent?.let { lineEvents -> + lineEvents.forEach { + it.updateStatus = EventDataBean.updated + it.upDateTime = System.currentTimeMillis() + } + EventDb.saveUpdateSuccess(lineEvents) + } + + waitUpdateWriteOffEvent?.let { writeOffEvents -> + WriteOffDb.saveUpdateSuccess(writeOffEvents, EventDataBean.updated, System.currentTimeMillis()) + } + + isUpdating.set(false) + createDefault.onNext(isUpdating.get()) + val queryWaitUpdateEventCount = EventDb.queryWaitUpdateEventCount() + if (queryWaitUpdateEventCount != null && queryWaitUpdateEventCount > 0) { + updateEvent() + return + } + + val queryWaitUpdateWriteOffCount = WriteOffDb.queryWaitUpdateWriteOffCount() + if (queryWaitUpdateWriteOffCount != null && queryWaitUpdateWriteOffCount > 0) { + updateEvent() + return + } + + RxUtils.disposeSubscribe(eventUpdateInfo) + eventUpdateInfo = RxUtils.createSubscribe(2 * 60 * 1000) { + updateEvent() + } + } + + override fun onFail(code: Int, msg: String?) { + isUpdating.set(false) + createDefault.onNext(isUpdating.get()) + d(TAG, "上报event-上报event失败 $transformDb2Net code:$code msg:$msg ") + OchChainLogManager.writeChainLogDb("上报event失败", "$transformDb2Net ") + RxUtils.disposeSubscribe(eventUpdateInfo) + eventUpdateInfo = RxUtils.createSubscribe(10 * 1000) { + updateEvent() + } + } + + override fun onError() { + isUpdating.set(false) + createDefault.onNext(isUpdating.get()) + d(TAG, "上报event-上报event失败 $transformDb2Net ") + OchChainLogManager.writeChainLogDb("上报event失败", "$transformDb2Net") + RxUtils.disposeSubscribe(eventUpdateInfo) + eventUpdateInfo = RxUtils.createSubscribe(10 * 1000) { + updateEvent() + } + } + }) + + } + + } + + fun queryWaitUploadInfo(): Observable>? { + return RepositoryManager.queryWaitUploadData() + } + + fun getUploadTaskObservable(): BehaviorSubject { + return createDefault + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/LineModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/LineModel.kt new file mode 100644 index 0000000000..e422bed347 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/LineModel.kt @@ -0,0 +1,407 @@ +package com.mogo.och.unmanned.model + +import android.annotation.SuppressLint +import android.content.Context +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.map.SiteMarkerBean +import com.mogo.eagle.core.data.och.OchInfo +import com.mogo.eagle.core.data.v2x.Point +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager +import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener +import com.mogo.eagle.core.function.call.och.CallerEagleBaseFunctionCall4OchManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.common.module.biz.login.LoginStatusManager +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.socket.lan.LanSocketManager +import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffResultMsg +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.data.bean.BusStationBean +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.callback.IBusLinesCallback +import com.mogo.och.unmanned.model.OrderModel.isGoingToNextStation +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean +import com.mogo.och.unmanned.repository.db.repository.EventDb +import com.mogo.och.unmanned.repository.db.repository.SiteDb +import com.mogo.och.unmanned.repository.exception.DataException +import com.mogo.och.unmanned.util.ShuttleVoiceManager +import io.reactivex.Observer +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers +import java.util.concurrent.ConcurrentHashMap + +/** + * @author: wangmingjun + * @date: 2022/2/9 + */ +@SuppressLint("StaticFieldLeak") +object LineModel { + private var mContext: Context? = null + + private val mBusLinesCallbackMap: MutableMap = ConcurrentHashMap() + + const val TAG = "${M_BUS}BusLineModel" + + var currentTask: TaskDataBean? = null + + // 当前任务的站点列表 + var stationList: MutableList? = mutableListOf() + + private var startTaskDisposable: Disposable? = null + + + // 当前站点 + @JvmStatic + var startStationIndex: Int = 0 //A->B 此处值是A站点索引 + + //下一站点 + @JvmStatic + var nextStationIndex: Int = 0 + + @JvmStatic + fun init() { + d(TAG, "init") + mContext = AbsMogoApplication.getApp() + EventModel.load() + SynchDataModel.queryCarExecutableTaskList(true) + } + + @JvmStatic + @Synchronized + fun release() { + d(TAG, "release") + mContext = null + + SynchDataModel.release() + EventModel.release() + mBusLinesCallbackMap.clear() + + } + + @JvmStatic + fun setBusLinesCallback(tag: String?, callback: IBusLinesCallback?) { + if (tag == null || "" == tag) return + if (callback == null) { + mBusLinesCallbackMap.remove(tag) + return + } + mBusLinesCallbackMap[tag] = callback + } + + fun getBusLinesCallbackMap(): MutableMap { + return mBusLinesCallbackMap + } + + fun refreshTask() { + SynchDataModel.queryCarExecutableTaskList(false) + } + + /** + * 开始任务 + */ + @JvmStatic + fun commitSwitchLineId(task: TaskDataBean, line: LineDataBean) { + RxUtils.disposeSubscribe(startTaskDisposable) + line.getLineIdAndName { lineId, lineName -> + task.getLineIdAndName { shiftsId, taskId, taskTime, taskDate -> + RepositoryManager.startTask(shiftsId, taskId, lineId, taskTime, lineName) + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer { + override fun onSubscribe(d: Disposable) { + startTaskDisposable = d + d(TAG, "commitSwitchLineId onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "commitSwitchLineId onError${e.printStackTrace()}") + if (RepositoryManager.supportDb()) { + if (e is DataException) { + OchChainLogManager.writeChainLog("开始任务", "${e.message}") +// ToastUtils.showShort("选择任务失败:${e.message}") + ToastUtils.showShort(R.string.module_och_choose_task_fail, e.message) + mBusLinesCallbackMap.forEach { + it.value.onChangeLineIdFail() + } + } + } else { + OchChainLogManager.writeChainLog("开始任务", "${e.message}") +// ToastUtils.showShort("选择任务失败:${e.message}") + ToastUtils.showShort(R.string.module_och_choose_task_fail, e.message) + mBusLinesCallbackMap.forEach { + it.value.onChangeLineIdFail() + } + } + } + + override fun onComplete() { + d(TAG, "commitSwitchLineId onComplete") + } + + override fun onNext(data: Boolean) { + d(TAG, "commitSwitchLineId onNext ${data}") + if (data) { + EventDb.saveEventTaskStart(shiftsId, taskId, lineId, taskTime, lineName, taskDate) + OrderModel.queryBusRoutes() + BizLoopManager.runInIoThread { + val querySiteByLineId = SiteDb.querySiteByLineId(lineId) + querySiteByLineId?.forEach { + if (it.seq == 1) { + LanSocketManager.sendMsgToClient(WriteOffResultMsg(-99, "", "", System.currentTimeMillis(), LineManager.lineInfos?.lineId + ?: 0, it.siteId ?: 0L)) + } + return@forEach + } + } + mBusLinesCallbackMap.forEach { + it.value.onChangeLineIdSuccess() + } + } + RxUtils.disposeSubscribe(startTaskDisposable) + } + }) + } + } + + } + + fun haveRunningTask() { + mBusLinesCallbackMap.forEach { callback -> + callback.value.onRunningTask() + } + } + + fun haveNoRunningTask() { + mBusLinesCallbackMap.forEach { callback -> + callback.value.onNoRunningTask() + } + } + + fun leaveStationSuccess() { + mBusLinesCallbackMap.forEach { map -> + map.value.onLeaveStaionSuccess() + } + } + + fun arrivedStationSuccess() { + LanSocketManager.sendMsgToClient(WriteOffResultMsg(-99, "", "", System.currentTimeMillis(), LineManager.lineInfos?.lineId + ?: 0, LineManager.getStations()?.first?.siteId?.toLong() ?: 0L)) + mBusLinesCallbackMap.forEach { callback -> + callback.value.onArriveStationSuccess() + } + } + + fun isLastStation(): Boolean? { + return if (stationList.isNullOrEmpty()) { + null + } else { +// startStationIndex == stationList!!.size - 1 + startStationIndex == getLastStationPos(stationList!!) + } + } + + private fun getLastStationPos(stationList: MutableList): Int { + for (index in stationList.indices.reversed()) { + val item = stationList[index] + if (item.tag != 2) { + return index + } + } + return stationList.lastIndex + } + + fun isLastStation(end: BusStationBean): Boolean { + return if (stationList.isNullOrEmpty()) { + false + } else { +// val last = stationList?.last() + val last = stationList!!.reversed().firstOrNull { it.tag != 2 } ?: stationList!!.last() + return last == end + } + } + + fun getTaskTime(): String { + return DateTimeUtil.formatLongToString( + currentTask?.taskStartTime ?: System.currentTimeMillis(), + DateTimeUtil.HH_mm + ) + } + + fun endTask(isSlideStop: Boolean) { + currentTask?.getLineIdAndName { shiftsId, taskId, taskTime, taskDate -> + LineManager.triggerCompleteTask(isSlideStop) + RepositoryManager.endTask(shiftsId, taskId) + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer { + override fun onSubscribe(d: Disposable) { + startTaskDisposable + d(TAG, "endTask onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "endTask onError${e.printStackTrace()}") + if (e is DataException) { + + } + if (RepositoryManager.supportDb()) { + isGoingToNextStation = false + + ThirdDeviceData.endTask() + ThirdDeviceData.sendTaskDetailsToClients() + ShuttleVoiceManager.endOrderBus() + // 取消自驾 + CallerAutoPilotControlManager.cancelAutoPilot() + currentTask = null + LineManager.setLineInfo(null) + LineManager.setStartAndEndStation(null, null) + LanSocketManager.sendMsgToClient(WriteOffResultMsg(-99, "", "", System.currentTimeMillis(), LineManager.lineInfos?.lineId + ?: 0, LineManager.getStations()?.first?.siteId?.toLong() + ?: 0L)) + LineModel.callEyeMap(1) + stationList = mutableListOf() + startStationIndex = 0 + mBusLinesCallbackMap.forEach { + it.value.onCompleteTask() + } + val changeInfo = + "taskId:${currentTask?.taskId}--lineInfo:${LineManager.lineInfos}" + OchChainLogManager.writeChainLog("结束任务", changeInfo) + } else { +// ToastUtils.showShort("结束任务失败请稍后再试") + ToastUtils.showShort(R.string.module_och_task_finish_fail) + mBusLinesCallbackMap.forEach { + it.value.onCompleteTaskFail() + } + } + LineManager.lastArrivedSiteId = -1 + } + + override fun onComplete() { + d(TAG, "endTask onComplete") + } + + override fun onNext(data: Boolean) { + d(TAG, "endTask onNext ${data}") + if (data) { + isGoingToNextStation = false + + ThirdDeviceData.endTask() + ThirdDeviceData.sendTaskDetailsToClients() + ShuttleVoiceManager.endOrderBus() + // 取消自驾 + CallerAutoPilotControlManager.cancelAutoPilot() + currentTask = null + LineManager.setLineInfo(null) + LineManager.setStartAndEndStation(null, null) + LanSocketManager.sendMsgToClient(WriteOffResultMsg(-99, "", "", System.currentTimeMillis(), LineManager.lineInfos?.lineId + ?: 0, LineManager.getStations()?.first?.siteId?.toLong() + ?: 0L)) + stationList = mutableListOf() + startStationIndex = 0 + LineModel.callEyeMap(2) + mBusLinesCallbackMap.forEach { + it.value.onCompleteTask() + } + val changeInfo = + "taskId:${currentTask?.taskId}--lineInfo:${LineManager.lineInfos}" + OchChainLogManager.writeChainLog("结束任务", changeInfo) + } + LineManager.lastArrivedSiteId = -1 + onComplete() + } + }) + } + } + + fun startTaskMessage(): Boolean { + if (!stationList.isNullOrEmpty()) { + return startStationIndex == 0 && stationList!!.first().drivingStatus == TaskSiteDataBean.drivingStatusCurrent && !stationList!!.first().isLeaving + } + return false + } + + fun setDemoMode() { + // 美化是否开始 + if (FunctionBuildConfig.isDemoMode) { //行驶过程中设置美化 + val (startStation, _) = LineManager.getStations() + if (startStation != null && startStation.isLeaving) { + OrderModel.startBeautificationMode() + d(TAG, "美化模式-ignore:置为true(每次滑动出发)") + } else if (startStationIndex > 0 && startStationIndex < stationList!!.size - 1) { + //美化模式下 中间站点到站 引导线要一直绘制,所以此处不出强制绘制不传false + CallerAutoPilotControlManager.setIPCDemoMode(false) + d(TAG, "美化模式-ignore:false(到达中间站)") + } else { + OrderModel.closeBeautificationMode() + } + } + } + + fun callEyeMap(index: Int) { + d(TAG, "执行${index} callEyeMap${stationList?.size}") + if (stationList.isNullOrEmpty()) { + val ochInfo = OchInfo(1, mutableListOf()) + ochInfo.siteMarkerList = mutableListOf() + CallerDataCenterBizListener.invokeOchInfo(ochInfo) + OchChainLogManager.writeChainLogMap("地图", "站点信息:${ochInfo}") + CallerEagleBaseFunctionCall4OchManager.updateOrderStatus(false) + } else { + CallerEagleBaseFunctionCall4OchManager.updateOrderStatus(true) + val siteList = mutableListOf() + var temp: SiteMarkerBean? = null + stationList?.let { + it.forEachIndexed { index, busStationBean -> + if (index == 0) { + temp = SiteMarkerBean(Point(busStationBean.gcjLon, busStationBean.gcjLat), R.drawable.unmanned_bus_station_start, 0.5f, 0.87f) + } else if (index == it.size - 1) { + temp = SiteMarkerBean(Point(busStationBean.gcjLon, busStationBean.gcjLat), R.drawable.unmanned_bus_station_end, 0.5f, 0.87f) + } else { + if (busStationBean.drivingStatus == 1) { + temp = SiteMarkerBean(Point(busStationBean.gcjLon, busStationBean.gcjLat), R.drawable.unmanned_bus_station_pass, 0.5f, 0.478f) + } else if (busStationBean.drivingStatus == 3) { + temp = SiteMarkerBean(Point(busStationBean.gcjLon, busStationBean.gcjLat), R.drawable.unmanned_bus_station_notarrive, 0.5f, 0.478f) + } else if (busStationBean.drivingStatus == 2) { + if (busStationBean.isLeaving) { + temp = SiteMarkerBean(Point(busStationBean.gcjLon, busStationBean.gcjLat), R.drawable.unmanned_bus_station_pass, 0.5f, 0.478f) + } else { + temp = SiteMarkerBean(Point(busStationBean.gcjLon, busStationBean.gcjLat), R.drawable.unmanned_bus_station_notarrive, 0.5f, 0.478f) + } + } + } + temp?.let { temp -> + siteList.add(temp) + } + } + } + val (start, end) = LineManager.getStations() + if (start != null && end != null) { + val ochInfo = OchInfo(1, mutableListOf(start.toMogoLocation(), end.toMogoLocation())) + ochInfo.siteMarkerList = siteList + CallerDataCenterBizListener.invokeOchInfo(ochInfo) + OchChainLogManager.writeChainLogMap("地图", "站点信息:${ochInfo}") + } + } + } + + fun endTaskByOther(taskId: Long, plateNumber: String) { + if (LoginStatusManager.getOchCarInfo()?.plateNumber == plateNumber) { + d(TAG, "当前车辆消耗任务") + return + } + RepositoryManager.endTaskByOther(taskId) + mBusLinesCallbackMap.forEach { callback -> + callback.value.onEndTaskByOther(taskId, plateNumber) + } + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/OrderModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/OrderModel.kt new file mode 100644 index 0000000000..0f1399dc2d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/OrderModel.kt @@ -0,0 +1,570 @@ +package com.mogo.och.unmanned.model + +import android.annotation.SuppressLint +import android.content.Context +import android.text.TextUtils +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.module.status.MogoStatusManager +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.setting.CallerSopSettingManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.CoordinateUtils +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bridge.autopilot.autopilot.IOchAutopilotStatusListener +import com.mogo.och.bridge.autopilot.autopilot.OchAutoPilotStatusListenerManager +import com.mogo.och.bridge.autopilot.autopilot.bean.ArrivedStation +import com.mogo.och.bridge.autopilot.line.ILineCallback +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.bridge.autopilot.location.OchLocationManager +import com.mogo.och.common.module.biz.birdge.BridgeListener +import com.mogo.och.common.module.biz.birdge.BridgeManager +import com.mogo.och.common.module.biz.login.LoginStatusManager +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.manager.socket.cloud.OCHSocketMessageManager +import com.mogo.och.common.module.manager.socket.lan.LedScreenManager +import com.mogo.och.common.module.manager.transform.OchTransform +import com.mogo.och.common.module.manager.transform.OchTransformDispatch +import com.mogo.och.common.module.map.MapMakerManager +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.common.module.utils.OCHThreadPoolManager +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.constant.BusConst +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean +import com.mogo.och.unmanned.repository.exception.DataException +import com.mogo.och.unmanned.util.BusTrajectoryManager +import com.mogo.och.unmanned.util.ShuttleVoiceManager +import io.reactivex.Observer +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers + +/** + * @author congtaowang + * @since 2021/3/23 + * + * + * 小巴订单管理 + */ +@SuppressLint("StaticFieldLeak") +object OrderModel { + private val TAG: String = M_BUS + OrderModel::class.java.simpleName + + private var mContext: Context? = null + + /** + * 用来表示是否正在开往下一站 + */ + @JvmStatic + var isGoingToNextStation: Boolean = false + + @Volatile + private var isArrivedStation = false + + @JvmStatic + fun init() { + mContext = AbsMogoApplication.getApp() + + ThirdDeviceData.init() + + // 加载核销模块 + TicketModel.load() + + OchAutoPilotStatusListenerManager.addListener(TAG, ochAutopilotStatusListener) + + BridgeManager.addBridgeListener(TAG, bridgeListener) + + LineManager.addListener(TAG, arriveStationBySearch) + + OchTransform.addListener(TAG, ochTransform) + + RxUtils.errCatch() + } + + @JvmStatic + fun release() { + // 注销定位监听 + + mContext = null + + ThirdDeviceData.release() + + TicketModel.release() + + OchAutoPilotStatusListenerManager.removeListener(TAG) + BridgeManager.removeBridgeListener(LineModel.TAG) + + LineManager.removeListener(TAG) + OchTransform.removeListener(TAG) + } + + private val bridgeListener = object : BridgeListener { + override fun onPncInfoListener(pncAction: String) { + if (TextUtils.equals(pncAction, StringUtils.getString(R.string.module_core_entering_the_station))) { + ShuttleVoiceManager.arrivedStationOut(ResourcesUtils.getString(R.string.unmanned_bus_voice_out_arriving_station)) + } +// when (pncAction) { +// OchCommonConst.PNC_ACTION_ENTERSTATION -> { +// ShuttleVoiceManager.arrivedStationOut(ResourcesUtils.getString(R.string.m2_voice_out_arriving_station)) +// } +// else -> {} +// } + } + } + + private val ochAutopilotStatusListener = object : IOchAutopilotStatusListener { + override fun onAutopilotArriveAtStation(arrivedStation: ArrivedStation?) { + e(TAG, "行程日志-onAutopilotArriveAtStation arrive") + onArriveAt(arrivedStation, "底盘触发进站") + } + + } + + private val ochTransform = object : OchTransformDispatch { + override fun logout() { + logoutInner() + } + } + + + // 自车定位 + private val arriveStationBySearch = object : ILineCallback { + override fun arrivedStationSuccessBySearch() { + //是否到站的围栏判断 离站状态并且自动驾驶还未触发到站 + if (isGoingToNextStation && !isArrivedStation) { + OCHThreadPoolManager.getsInstance().locationExecute { + onArriveAt(null, "兜底:距离站点15m内 每秒钟向底盘查询是否到站 底盘返回") + } + } + } + + override fun sendStartAutopilotSuccessAck() { + //底盘收到启动自驾的回执 + BizLoopManager.setLoopFunction(TAG, LoopInfo(2, ::calculateDistanceAndAutoStatus, scheduler = Schedulers.io())) + } + } + + // 在站点15m内且启动自动驾驶成功后播报,每次启动仅播报1次 + private fun calculateDistanceAndAutoStatus() { + val (start, _) = LineManager.getStations() + if (start == null) { + BizLoopManager.removeLoopFunction(TAG) + } else { + val startLon = start.gcjLon + val startLat = start.gcjLat + val mogoLocation = OchLocationManager.getGCJ02Location() + val distance = CoordinateUtils.calculateLineDistance( + startLon, startLat, + mogoLocation.longitude, mogoLocation.latitude + ) + if (distance < BusConst.SEND_OUTVOICE_DISTANCES_TARTSTATIONE) { + if (OchAutoPilotStatusListenerManager.autopilotState == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + ShuttleVoiceManager.arrivedStationOut(ResourcesUtils.getString(R.string.unmanned_bus_voice_out_autopilot_start_in15m)) + BizLoopManager.removeLoopFunction(TAG) + } + } else { + BizLoopManager.removeLoopFunction(TAG) + } + } + } + + + /** + * 查询小巴路线 + */ + @JvmStatic + fun queryBusRoutes() { + d(TAG, "查询小巴路线") + RepositoryManager.loadCurrentTaskInfo() + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer { + override fun onSubscribe(d: Disposable) { + d(TAG, "queryBusRoutes onSubscribe") + } + + override fun onError(e: Throwable) { + e.printStackTrace() + d(TAG, "queryBusRoutes onError${e.printStackTrace()}") + e.printStackTrace() + LineModel.haveNoRunningTask() + d(TAG, "queryBusRoutes 获取到小巴路线数据:空 ") + LineManager.setLineInfo(null) + updateBusStatus() + closeBeautificationMode() + removeTipRunnables() + } + + override fun onComplete() { + d(TAG, "queryBusRoutes onComplete") + } + + override fun onNext(data: Boolean) { + if (data) { + MogoStatusManager.getInstance().setShuttleDriverPerformTask(TAG, true) + LineModel.haveRunningTask() + updateBusStatus() + } else { + MogoStatusManager.getInstance().setShuttleDriverPerformTask(TAG, false) + LineModel.haveNoRunningTask() + d(TAG, "queryBusRoutes 获取到小巴路线数据:空 ") + LineManager.setLineInfo(null) + updateBusStatus() + closeBeautificationMode() + removeTipRunnables() + } + } + + }) + } + + /** + * 重置路线站点状态--结束路线,当前路线恢复到始发站 + * @param isSlideStop true:单程结束(订单完成正常滑动结束) false:订单未完成结束(点击结束按钮结束) + */ + @JvmStatic + fun completeTask(isSlideStop: Boolean) { + OCHThreadPoolManager.getsInstance().execute { + d(TAG, "结束当前路线abortTask") + removeTipRunnables() + LineModel.endTask(isSlideStop) + } + } + + private fun onStartAutopilot() { + //开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启 + isGoingToNextStation = true + if (CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + ) { + LineManager.startAutopilot(true) + } + } + + @JvmStatic + fun startBeautificationMode() { + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true + CallerAutoPilotControlManager.setIgnoreConditionDraw(true) + CallerAutoPilotControlManager.setIPCDemoMode(true) + } + + + /** + * 关闭美化模式 + */ + @JvmStatic + fun closeBeautificationMode() { + if (FunctionBuildConfig.isDemoMode) { //收车结束美化 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false //是否强制绘制引导线 + CallerAutoPilotControlManager.setIgnoreConditionDraw(false) // 同步给乘客屏 + CallerAutoPilotControlManager.setIPCDemoMode(false) //是否自动启动自驾 + d(TAG, "美化模式-ignore:置为false") + } + } + + /** + * 滑动出发 + */ + @JvmStatic + fun driveToNextStation() { + if (LineModel.isLastStation() == true) { + // 当前站是最后一站,结束当前行程 + completeTask(true) + return + } + + LineManager.getStations().first?.let { startStation -> + startStation.drivingStatus = TaskSiteDataBean.drivingStatusCurrent + startStation.isLeaving = true + LineModel.currentTask?.let { task -> + RepositoryManager.leaveStation( + startStation.seq, + startStation.siteId.toLong(), + task.shiftsId ?: 0L, + task.taskId ?: 0L, + task.lineId ?: 0L, + task.taskStartTime ?: System.currentTimeMillis(), + task.taskDate ?: 0L + ) + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer { + override fun onSubscribe(d: Disposable) { + d(TAG, "driveToNextStation onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "driveToNextStation onError${e.printStackTrace()}") + if (e is DataException) { + e.printStackTrace() + } + LineModel.leaveStationSuccess() + isArrivedStation = false + onStartAutopilot() + + ThirdDeviceData.leaveStation() + + updateBusStatus() + + LineModel.callEyeMap(3) + } + + override fun onComplete() { + d(TAG, "onComplete") + } + + override fun onNext(data: Boolean) { + d(TAG, "driveToNextStation onComplete") + if (data) { + LineModel.leaveStationSuccess() + isArrivedStation = false + onStartAutopilot() + + ThirdDeviceData.leaveStation() + + updateBusStatus() + LineModel.callEyeMap(4) + } + } + }) + } + } + + } + + /** + * 渲染站点信息 + * 服务端返回的OchBusRoutesResult逻辑, 离开站为当前站, 到达下一站后才会将下一站置为当前站, + * 车机端展示 三站: 中间为即将到到达或者刚到达的站 + * queryBusRoutes + * queryBusRoutes + * queryBusRoutes + * driveToNextStation + * onArriveAt + */ + private fun updateBusStatus() { + val (startStation, endStation) = LineManager.getStations() + if (startStation != null && endStation != null) { + if (startStation.isLeaving) {// 出发需要移除 + MapMakerManager.removeMapMaker(BusConst.BUS_START_MAP_MAKER, startStation.lat, startStation.lon) + } else {// 为出发展示 + MapMakerManager.addMapMaker(TAG, BusConst.BUS_START_MAP_MAKER, startStation.lat, startStation.lon, R.raw.star_marker) + } + MapMakerManager.addMapMaker(TAG, BusConst.BUS_END_MAP_MAKER, endStation.lat, endStation.lon, R.raw.end_marker) + } else { + MapMakerManager.removeAllMapMarkerByOwner(TAG) + } + + LineModel.stationList?.let { + if (LineModel.startTaskMessage()) { //默认是第一站到站查询 + LineManager.lineInfos?.lineName?.let { lineName -> + LedScreenManager.sendTripInfo2Led( + LedScreenManager.START_TRIP, + lineName, "", "", false + ) + } + //任务选择后首发前给司机提示任务 + beforeTaskTips() + } else { + removeTipRunnables() + } + + + LineModel.setDemoMode() + + LineManager.getStartStation { + isGoingToNextStation = it.isLeaving + } + + ThirdDeviceData.sendTaskDetailsToClients() + + //需放在currentStationIndex赋值之后 + BusTrajectoryManager.syncTrajectoryInfo() + } + } + + private fun beforeTaskTips() { + if (LineModel.currentTask == null) return + + removeTipRunnables() + + val taskTime = LineModel.currentTask!!.taskStartTime ?: return + val tip3Time = taskTime - 3 * 60 * 1000 - DateTimeUtil.getCurrentTimeStamp() // 首站离开前3分钟提示 + val tip1Time = taskTime - 60 * 1000 - DateTimeUtil.getCurrentTimeStamp() // 首站离开前1分钟提示 + + if (tip3Time > 0) { + UiThreadHandler.postDelayed(tip3Runnable, tip3Time) + } + + if (tip1Time > 0) { + UiThreadHandler.postDelayed(tip1Runnable, tip1Time) + } + } + + private var tip3Runnable = Runnable { + + if (LineModel.startTaskMessage()) { + tipStartTask("3") + } else { + removeTipRunnables() + } + } + + private var tip1Runnable = Runnable { + if (LineModel.startTaskMessage()) { + tipStartTask("1") + } else { + removeTipRunnables() + } + } + + private fun tipStartTask(s: String) { + val tips = ResourcesUtils.getString(R.string.unmanned_bus_before_tips_s, s) + //展示在运营消息 + OCHSocketMessageManager.pushAppOperationalMsgBox( + DateTimeUtil.getCurrentTimeStamp(), + tips, OCHSocketMessageManager.OPERATION_SYSTEM + ) + ShuttleVoiceManager.showLeafTime(tips) + } + + + private fun removeTipRunnables() { + UiThreadHandler.removeCallbacks(tip3Runnable) + UiThreadHandler.removeCallbacks(tip1Runnable) + } + + /** + * 到站 + * + * @param data + */ + @JvmStatic + fun onArriveAt(data: ArrivedStation?, type: String) { + if (LineManager.getStations().second == null) { + e(TAG, "行程日志-到站异常,取消后续操作结束") + OchChainLogManager.writeChainLog("shuttle弱网", "$type 行程日志-到站异常,取消后续操作结束") + return + } + if (data != null) { + d(TAG, "地盘到站${data}") + } + + //MAP 280 每隔100ms左右返回一次到站, 导致在到达中间站后再次滑动出发后会有时间差,收到一次到站,出现问题 + //此处比对 自驾告诉的到站站点坐标和本地应到站站点坐标, 一致时才能到站 + LineManager.getStations { start, end -> + + if (isArrivedStation || end.siteId == LineManager.lastArrivedSiteId) return@getStations + + OchChainLogManager.writeChainLog("触发进站", type) + LineManager.lastArrivedSiteId = end.siteId + isArrivedStation = true + isGoingToNextStation = false + start.drivingStatus = TaskSiteDataBean.drivingStatusPassed + start.isLeaving = false + end.drivingStatus = TaskSiteDataBean.drivingStatusCurrent + RepositoryManager.arriveStation(end.seq, end.siteId.toLong(), LineModel.currentTask?.taskId + ?: 0L) + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer { + override fun onSubscribe(d: Disposable) { + d(TAG, "onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "onError${e.printStackTrace()}") + if (e is DataException) { + e.printStackTrace() + } + ThirdDeviceData.arriveStation() + d(TAG, "arrivedStation onComplete") + LineModel.stationList?.let { + //此处始发站应为上段路程的终点站 + LineModel.startStationIndex = LineModel.nextStationIndex + val startStation = LineManager.getStations().second + if (LineModel.startStationIndex + 1 < it.size) { + //遍历当前路段起始点之后的数组,第一个正常停靠点即为该段终点 + val subStationList = it.subList(LineModel.startStationIndex + 1, it.size) + val endStation = subStationList.firstOrNull { bean -> + bean.tag != 2 + } + LineModel.nextStationIndex = it.indexOf(endStation) +// val endStation = stationlist[LineModel.startStationIndex + 1] + LineManager.setStartAndEndStation(startStation, endStation) + LineModel.callEyeMap(5) + } + } + LineModel.arrivedStationSuccess() + updateBusStatus() + } + + override fun onComplete() { + ThirdDeviceData.arriveStation() + d(TAG, "arrivedStation onComplete") + LineModel.stationList?.let { + //此处始发站应为上段路程的终点站 + LineModel.startStationIndex = LineModel.nextStationIndex + val startStation = LineManager.getStations().second + if (LineModel.startStationIndex + 1 < it.size) { + //遍历当前路段起始点之后的数组,第一个正常停靠点即为该段终点 + val subStationList = it.subList(LineModel.startStationIndex + 1, it.size) + val endStation = subStationList.firstOrNull { bean -> + bean.tag != 2 + } + LineModel.nextStationIndex = it.indexOf(endStation) +// val endStation = stationlist[LineModel.startStationIndex + 1] + LineManager.setStartAndEndStation(startStation, endStation) + LineModel.callEyeMap(6) + } + } + LineModel.arrivedStationSuccess() + updateBusStatus() + } + + override fun onNext(data: Boolean) { + + } + }) + + } + + } + + // 登出 + @JvmStatic + fun logoutInner() { + ThreadUtils.getIoPool().execute { + try { + if (RepositoryManager.haveDataWaitSyn()) { + ToastUtils.showShort(ResourcesUtils.getString(R.string.unmanned_shuttle_logout_error)) + return@execute + } + if (RepositoryManager.haveRunningTask()) { + ToastUtils.showShort(ResourcesUtils.getString(R.string.unmanned_shuttle_logout_error_running)) + return@execute + } + } catch (e: Exception) { + OchChainLogManager.writeChainLog("错误", "${e.message}") + } + MogoStatusManager.getInstance().setShuttleDriverPerformTask(TAG, false) + MogoStatusManager.getInstance().setTaxiUnmanedDriverLineRoutingVerifyMode(TAG, false) + CallerSopSettingManager.invokeRoutingListener(false) + MapMakerManager.removeAllMapMarkerByOwner(TAG) + LineManager.lastArrivedSiteId = -1 + BusTrajectoryManager.stopTrajReqLoop() + LoginStatusManager.loginOut() + } + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/SynchDataModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/SynchDataModel.kt new file mode 100644 index 0000000000..5a1287d743 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/SynchDataModel.kt @@ -0,0 +1,197 @@ +package com.mogo.och.unmanned.model + +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.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i +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.network.OchCommonServiceCallback +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.repository.PointDb +import io.reactivex.Observer +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers +import java.util.concurrent.atomic.AtomicBoolean + +object SynchDataModel { + + private const val TAG = "SynchDataModel" + + private val isRequesting = AtomicBoolean(false) + + // 展示上一次刷新时间 + const val EXECUTABLECHANGETIME = "executablechangetime" + + private var queryCarInfo: Disposable? = null + + // 判断接口是否变化 + private const val EXECUTABLECHANGEMD5 = "EXECUTABLECHANGEMD5" + + /** + * 同步基础信息 + */ + fun queryCarExecutableTaskList(isBackground: Boolean) { + RxUtils.disposeSubscribe(queryCarInfo) + if (isRequesting.get()) { + d(TAG, "正在同步请稍等") + val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(EXECUTABLECHANGETIME, 0) + LineModel.getBusLinesCallbackMap().forEach { callback -> + callback.value.onRefreshSuccess(lastUpdateTime) + } + return + } + isRequesting.set(true) + d(TAG, "开始同步数据") + RepositoryManager.queryCarExecutableTaskList( + object : OchCommonServiceCallback { + override fun onSuccess(data: CarExecutableTaskResponse) { + isRequesting.set(false) + i(TAG, "查询路线和站点的数据为:${data.data}") + RxUtils.disposeSubscribe(queryCarInfo) + queryCarInfo = RxUtils.createSubscribe(60_000) { + queryCarExecutableTaskList(true) + } + // 第一次过滤 请求返回值的md5 + val currentRequest = DigestUtils.md5Hex(data.data.toString()) + val lastChangeMd5 = SharedPrefsMgr.getInstance().getString(EXECUTABLECHANGEMD5) + val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(EXECUTABLECHANGETIME, 0) + val currentTimeStamp = DateTimeUtil.getCurrentTimeStamp() + + SharedPrefsMgr.getInstance().putLong(EXECUTABLECHANGETIME, currentTimeStamp) + val sameDay = DateTimeUtil.isSameDay(currentTimeStamp, lastUpdateTime) + LineModel.getBusLinesCallbackMap().forEach { callback -> + callback.value.onRefreshSuccess(currentTimeStamp) + } + if (isBackground) { + if (currentRequest == lastChangeMd5 && sameDay) { + return + } + } + SharedPrefsMgr.getInstance().putString(EXECUTABLECHANGEMD5, currentRequest) + OchChainLogManager.writeChainLog( + "数据发生变化", + "接口信息发生变化 $lastChangeMd5 new md5${currentRequest}" + ) + val startTime = System.currentTimeMillis() + CarExecutableTaskResponse.save2Db(data) + d(TAG, "更新数据耗时${System.currentTimeMillis() - startTime}") + RxUtils.createSubscribe(800) { + // 等待写入数据库 + LineModel.getBusLinesCallbackMap().forEach { callback -> + callback.value.onRefreshSuccessWIthData() + } + } + } + + override fun onError() { + isRequesting.set(false) + d(TAG, "同步数据失败 onError") + RxUtils.disposeSubscribe(queryCarInfo) + queryCarInfo = RxUtils.createSubscribe(60_000) { + queryCarExecutableTaskList(true) + } + if (!isBackground) { + if (!NetworkUtils.isConnected(AbsMogoApplication.getApp())) { + ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip)) + } else { + ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip)) + } + } + } + + override fun onFail(code: Int, failMsg: String) { + isRequesting.set(false) + d(TAG, "同步数据失败 onFail") + RxUtils.disposeSubscribe(queryCarInfo) + queryCarInfo = RxUtils.createSubscribe(60_000) { + queryCarExecutableTaskList(true) + } + if (!isBackground) { + if (!NetworkUtils.isConnected(AbsMogoApplication.getApp())) { +// ToastUtils.showShort("网络异常,请稍后重试") + ToastUtils.showShort(R.string.module_och_network_error) + } else { + ToastUtils.showShort(failMsg) + } + } + + } + }) + } + + private val waitSysData = mutableSetOf() + private val isRequestingContrainInfo = AtomicBoolean(false) + + + fun synContraiInfo(needUpdatePoint: MutableList) { + waitSysData.addAll(needUpdatePoint) + if (isRequestingContrainInfo.get()) { + // 正在请求 + OchChainLogManager.writeChainLogNet(false, "同步轨迹", "正在同步轨迹请稍等 ") + return + } + isRequestingContrainInfo.set(true) + + val lines = mutableListOf() + waitSysData.forEach { + lines.add(it) + } + OchChainLogManager.writeChainLogNet(false, "同步轨迹", "轨迹变更需同步禁行点和途径点 线路:${lines}") + RepositoryManager.queryPointFromNet(lines) + ?.subscribeOn(Schedulers.io()) + ?.observeOn(Schedulers.io()) + ?.subscribe(object : Observer> { + override fun onSubscribe(d: Disposable) { + d(TAG, "queryPointsByLinesId onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "同步轨迹 onError${e.printStackTrace()} 同步轨迹失败 5s种后重试 线路:${lines}") + OchChainLogManager.writeChainLogNet(false, "同步轨迹", "同步轨迹失败 5s种后重试 线路:${lines}") + RxUtils.createSubscribe(5_000) { + synContraiInfo(needUpdatePoint) + } + isRequestingContrainInfo.set(false) + } + + override fun onComplete() { + d(TAG, "endTask onComplete") + } + + override fun onNext(data: List) { + try { + i(TAG, "途经点和轨迹信息为:${data}") + PointDb.addOrUpdate(data) + for (datum in data) { + waitSysData.remove(datum.lineId) + } + isRequestingContrainInfo.set(false) + if (waitSysData.isNotEmpty()) { + synContraiInfo(needUpdatePoint) + } + OchChainLogManager.writeChainLogNet(false, "同步轨迹", "网络请求重构 轨迹信息${data}") + d(TAG, "同步轨迹网络成功") + } catch (e: Exception) { + isRequestingContrainInfo.set(false) + OchChainLogManager.writeChainLogDb("同步轨迹", "同步轨迹时报错 轨迹信息${data} 错误信息${e.message}") + synContraiInfo(needUpdatePoint) + } + + } + }) + } + + fun release() { + isRequesting.set(false) + RxUtils.disposeSubscribe(queryCarInfo) + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/ThirdDeviceData.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/ThirdDeviceData.kt new file mode 100644 index 0000000000..edc4920ab0 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/ThirdDeviceData.kt @@ -0,0 +1,198 @@ +package com.mogo.och.unmanned.model + +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.bridge.distance.IDistanceListener +import com.mogo.och.bridge.distance.TrajectoryAndDistanceManager +import com.mogo.och.common.module.biz.birdge.BridgeListener +import com.mogo.och.common.module.biz.birdge.BridgeManager +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.common.module.manager.socket.cloud.AbnormalFactorsLoopManager +import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager +import com.mogo.och.common.module.manager.socket.cloud.action.OperateAction +import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener +import com.mogo.och.common.module.manager.socket.lan.LanSocketManager +import com.mogo.och.common.module.manager.socket.lan.LedScreenManager +import com.mogo.och.common.module.manager.socket.lan.bean.BusinessType +import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType +import com.mogo.och.common.module.manager.socket.lan.bean.TaskDetailsMsg +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.data.bean.BusTransferData +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.action.TaskUsedAction +import com.mogo.och.unmanned.constant.BusConst +import com.mogo.och.unmanned.util.ShuttleVoiceManager + +object ThirdDeviceData { + + const val TAG = M_BUS + "ThirdDeviceData" + + @JvmStatic + val busRoutesResult: BusRoutesResult = BusRoutesResult() + + private val bridgeListener: BridgeListener = object : BridgeListener { + override fun onCollisionRisk() { + ShuttleVoiceManager.collisionRisk() + } + } + private val trajectoryListener: IDistanceListener = object : IDistanceListener { + override fun distanceCallback(distance: Float) { + // 小于200m 播报站点介绍 + if (distance < 200) { + LineManager.getStations { start, end -> + if (!end.isPlayTts) { + end.isPlayTts = true + if (StringUtils.isEmpty(end.introduction)) { + if (!StringUtils.isEmpty(end.name)) { +// val message = "前方到站:${end.name},请下车的乘客做好准备" + val message = StringUtils.getString(R.string.module_och_next_station, end.name) + ShuttleVoiceManager.leave200Distance(message) + } + } else { + end.introduction?.let { + ShuttleVoiceManager.leave200Distance(it) + } + } + } + } + } + } + } + + fun init() { + //监听运营消息 + OCHSocketMessageManager.registerSocketMessageListener( + OCHSocketMessageManager.msgMonitorType, + OperateAction(true) + ) + + OCHSocketMessageManager.registerSocketMessageListener( + OCHSocketMessageManager.msgTaskUsedType, + TaskUsedAction() + ) + + // 长链接监听 + AbnormalFactorsLoopManager.startLoopAbnormalFactors(AbsMogoApplication.getApp()) + + //监听乘客屏发来的消息 + LanSocketManager.registerSocketMessageListener( + DPMsgType.TYPE_TASK_DETAILS.type, + taskDetailsMsgListener + ) + TrajectoryAndDistanceManager.addDistanceListener(TAG, trajectoryListener) + BridgeManager.addBridgeListener(TAG, bridgeListener) + } + + fun release() { + + OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgMonitorType) + + OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgTaskUsedType) + + AbnormalFactorsLoopManager.stopLoopAbnormalFactors() + + TrajectoryAndDistanceManager.removeListener(TAG) + + BridgeManager.removeBridgeListener(TAG) + + //监听乘客屏发来的消息 + LanSocketManager.unRegisterSocketMessageListener( + DPMsgType.TYPE_TASK_DETAILS.type, + taskDetailsMsgListener + ) + } + + // 乘客屏请求线路信息 + private val taskDetailsMsgListener = object : ILanMessageListener { + override fun targetLan(): Class = TaskDetailsMsg::class.java + override fun onLanMsgReceived(taskDetailsMsg: TaskDetailsMsg?) = sendTaskDetailsToClients() + } + + private var delayedTts: Runnable? = null + + // 离站 + fun leaveStation() { + LineManager.getStationsWithLine { start, end, lineInfo -> + delayedTts = object : Runnable { + override fun run() { + ShuttleVoiceManager.leaveStationBus(end.name, end.nameKr) + } + } + UiThreadHandler.postDelayed(delayedTts, BusConst.DELAY_10S) + //给bus外屏发送 + LedScreenManager.sendTripInfo2Led( + LedScreenManager.LEAVE_STATION, + lineInfo.lineName, + start.name ?: "", + end.name ?: "", + LineModel.isLastStation() == true + ) + } + } + + //到站 + fun arriveStation() { + delayedTts?.let { + UiThreadHandler.removeCallbacks(delayedTts) + } + LineManager.getStationsWithLine { start, end, lineInfo -> + ShuttleVoiceManager.arrivedStationBus(end.name, end.nameKr) + // 收到正在进站的决策信息时播报,每个站点仅播报1次 + ShuttleVoiceManager.arrivedStationOut(ResourcesUtils.getString(R.string.unmanned_bus_voice_out_arrive_station)) + //给bus外屏发送 + LedScreenManager.sendTripInfo2Led( + LedScreenManager.ARRIVE_STATION, + lineInfo.lineName, + start.name ?: "", + end.name ?: "", + LineModel.isLastStation(end) + ) + } + } + + //结束任务 + fun endTask() { + delayedTts?.let { + UiThreadHandler.removeCallbacks(delayedTts) + } + LineManager.getLineInfo { lineInfo -> + LedScreenManager.sendTripInfo2Led( + LedScreenManager.END_TRIP, + lineInfo.lineName, + "", + "", + false + ) + } + } + + fun sendTaskDetailsToClients() { + if (LineManager.lineInfos == null || LineModel.currentTask == null || LineModel.stationList.isNullOrEmpty()) { + val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, null) + val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) + d(TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) + LanSocketManager.sendMsgToClient(msg) + } else { + LineManager.getLineInfo { lineInfo -> + busRoutesResult.setSite(LineModel.stationList) + busRoutesResult.lineId = lineInfo.lineId.toInt() + busRoutesResult.name = lineInfo.lineName + busRoutesResult.taskId = LineModel.currentTask!!.taskId!!.toInt() + busRoutesResult.taskTime = LineModel.currentTask!!.taskStartTime!! + busRoutesResult.writeVersion = System.currentTimeMillis() + val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, busRoutesResult) + val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) + d(TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) + LanSocketManager.sendMsgToClient(msg) + } + } + + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/TicketModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/TicketModel.kt new file mode 100644 index 0000000000..9e3914a207 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/model/TicketModel.kt @@ -0,0 +1,325 @@ +package com.mogo.och.unmanned.model + +import com.elegant.network.utils.GsonUtil +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.data.enums.EventTypeEnumNew +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.data.msgbox.MsgBoxType +import com.mogo.eagle.core.data.msgbox.V2XMsg +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.bridge.autopilot.line.LineManager +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.manager.socket.cloud.IOchOnMessageListener +import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager +import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener +import com.mogo.och.common.module.manager.socket.lan.LanSocketManager +import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType +import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg +import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffResultMsg +import com.mogo.och.common.module.utils.OchPhoneUtil +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.bean.WriteOffPassenger +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.exception.DataException +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse +import com.mogo.och.unmanned.util.ShuttleVoiceManager +import io.reactivex.Observable +import io.reactivex.ObservableEmitter +import io.reactivex.ObservableOnSubscribe +import io.reactivex.Observer +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers + +object TicketModel { + + private const val TAG = M_BUS + "TicketModel" + + private const val SELECTWRITEOFFCOUNT = "SELECTWRITEOFFCOUNT" + + private var emitterMain: ObservableEmitter>? = null + + /** + * 接受乘客端扫码数据进行云端和本地核销 + */ + private val writeOffDetialMsg = object : ILanMessageListener { + override fun targetLan(): Class = WriteOffDetialMsg::class.java + override fun onLanMsgReceived(obj: WriteOffDetialMsg?) = receiveWrteOffDefailtInfo(obj) + } + + /** + * 接受乘客端扫码数据进行云端和本地核销 + */ + private val writeOffOnlineMsg = object : IOchOnMessageListener { + override fun target(): Class { + return WriteOffPassenger::class.java + } + + override fun onMsgReceived(passenger: WriteOffPassenger?) { + //进行播报 + i(TAG, "后台socket 核验:passenger = " + GsonUtil.jsonFromObject(passenger)) + if (passenger == null || passenger.passengerSize == 0) { + return + } + RepositoryManager.saveWriteOff4Socket(passenger) + writeOffSuccess( + passenger.passengerSize, + passenger.phone ?: "", + "", + passenger.ticketName ?: "", + 0 + ) + } + } + + private val observable = Observable.create(ObservableOnSubscribe> { emitter -> emitterMain = emitter }) + + fun getWriteOffCountObservable(): Observable> { + return observable + } + + fun load() { + // 3s轮训站点核销人数 人数本地核销 直接计算就好 + if (RepositoryManager.supportWriteOff() && RepositoryManager.supportWriteOffDb()) { + BizLoopManager.setLoopFunction( + SELECTWRITEOFFCOUNT, + LoopInfo(3, TicketModel::selectWriteOffCount, scheduler = Schedulers.io()) + ) + } + // 核销信息 + LanSocketManager.registerSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_DETAIL.type, writeOffDetialMsg) + + //监听核销乘客 + OCHSocketMessageManager.registerSocketMessageListener(OCHSocketMessageManager.msgWriteOffPassengerType, writeOffOnlineMsg) + } + + fun release() { + if (RepositoryManager.supportWriteOff()) { + BizLoopManager.removeLoopFunction(SELECTWRITEOFFCOUNT) + } + LanSocketManager.unRegisterSocketMessageListener(DPMsgType.TYPE_WRITEOFF_INFO_DETAIL.type, writeOffDetialMsg) + OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgWriteOffPassengerType) + } + + private fun selectWriteOffCount() { + LineManager.getStations().first?.let { firstStation -> + LineModel.currentTask?.let { currentTask -> + val queryWriteoffCount = RepositoryManager.queryWriteoffCount( + AbsMogoApplication.getApp(), + currentTask.taskId ?: 0L, + firstStation.siteId.toLong() + ) + if (queryWriteoffCount != null) { + queryWriteoffCount.subscribe( + object : Observer { + override fun onSubscribe(d: Disposable) { + + } + + override fun onError(e: Throwable) { + + } + + override fun onComplete() { + + } + + override fun onNext(count: Int) { + emitterMain?.onNext(Pair(firstStation.siteId, count)) + d(TAG, "${firstStation.name}核销人数:${count}") + OchChainLogManager.writeChainLog( + "核销人数", + "任务:${currentTask.taskId} 站点:${firstStation.siteId}_${firstStation.name}" + ) + } + + } + ) + return + } + } + + } + emitterMain?.onNext(Pair(0, 0)) + d(TAG, "线路或者站点为空") + } + + + private fun receiveWrteOffDefailtInfo(writeOffDetialMsg: WriteOffDetialMsg?) { + writeOffDetialMsg?.let { + if (writeOffDetialMsg.code != 0) { + sendMessage2Driver( + writeOffDetialMsg.msg ?: "", + writeOffDetialMsg.phone ?: "", + writeOffDetialMsg.code, + writeOffDetialMsg.orderNo ?: "", + ) + } else { + RepositoryManager.writeOff(writeOffDetialMsg) + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer { + override fun onSubscribe(d: Disposable) { + d(TAG, "receiveWrteOffDefailtInfo onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "receiveWrteOffDefailtInfo onError${e.printStackTrace()}") + if (e is DataException) { + d(TAG, "核销失败 ${e.code}-----${e.msg}") + parseData(e.code, e.msg ?: "", writeOffDetialMsg.phone + ?: "", writeOffDetialMsg.orderNo ?: "") + } + try { + OchChainLogManager.writeChainLogWriteOff("核销失败", "原因${e.message}") + } catch (e: Exception) { + + } + } + + override fun onComplete() { + d(TAG, "receiveWrteOffDefailtInfo onComplete") + } + + override fun onNext(data: PassengerWriteOffResponse.Result) { + d(TAG, "queryBusLines onNext ${data}") + writeOffSuccess( + data.ticketSize ?: 0, + data.phone ?: "", + writeOffDetialMsg.orderNo ?: "", + data.ticketName ?: "", + data.businessTime ?: System.currentTimeMillis(), + ) + try { + OchChainLogManager.writeChainLogWriteOff("核销成功", "原因$data") + } catch (e: Exception) { + + } + } + }) + } + } + } + + /** + * 解析错误原因 + */ + private fun parseData(code: Int, msg: String, phone: String, orderNo: String) { + when (code) { +// 1009 -> sendMessage2Driver("乘车日期非今日", phone,1009,orderNo) + 1009 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_travel_date_not_today), phone, 1009, orderNo) +// 1005 -> sendMessage2Driver("当前无路线任务", phone,1005,orderNo) + 1005 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_there_are_no_route_tasks), phone, 1005, orderNo) +// 1006 -> sendMessage2Driver("车票非当前路线", phone,1006,orderNo) + 1006 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_ticket_not_current_route), phone, 1006, orderNo) +// 1008 -> sendMessage2Driver("车票无剩余可用次数", phone,99,orderNo) + 1008 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_ticket_has_no_remaining_valid_rides_available), phone, 99, orderNo) +// 6001 -> sendMessage2Driver("二维码已过期", phone,6001,orderNo) + 6001 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_qr_code_expired), phone, 6001, orderNo) +// 6002 -> sendMessage2Driver("同一订单核销间隔时间需大于2分钟", phone,6002,orderNo) + 6002 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_interval_canceling_same_order_too_short), phone, 6002, orderNo) +// 6003 -> sendMessage2Driver("车票非当前站点", phone,6003,orderNo) + 6003 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_ticket_not_valid_for_current_station), phone, 6003, orderNo) +// 6004 -> sendMessage2Driver("车辆未执行任务", phone,6004,orderNo) + 6004 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_vehicle_not_duty), phone, 6004, orderNo) +// 6005 -> sendMessage2Driver("车票非当前班次", phone,6005,orderNo) + 6005 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_ticket_not_for_current_train), phone, 6005, orderNo) +// 1012 -> sendMessage2Driver("车票与车辆所属租户不一致", phone,1012,orderNo) + 1012 -> sendMessage2Driver(StringUtils.getString(R.string.module_och_ticket_does_not_match_tenant_who_owns_vehicle), phone, 1012, orderNo) + else -> { + try { + val tempcode = msg.toInt() + parseData(tempcode, msg, phone, orderNo) + } catch (e: Exception) { + sendMessage2Driver(msg, phone, 3002, orderNo) + } + } + } + } + + /** + * 验票失败 + * code 3001 乘客屏参数校验失败 + * code 3002 司机屏校验失败原因未知 + * code 99 小程序缓存丢失Android 缓存存在 + */ + private fun sendMessage2Driver(message: String, phone: String, code: Int, orderNo: String) { + // 发送乘客屏 通过蓝牙告知小程序 + LanSocketManager.sendMsgToClient(WriteOffResultMsg(code, phone, orderNo, System.currentTimeMillis(), LineManager.lineInfos?.lineId + ?: 0, LineManager.getStations()?.first?.siteId?.toLong() ?: 0L)) +// val failedReason = "核销失败,${message}" + val failedReason = StringUtils.getString(R.string.module_och_recognition_failed, message) + // tts + ShuttleVoiceManager.writeOffFaile(failedReason) + val tempPhone = OchPhoneUtil.getPhoneWithoutMiddle(phone) + val reaseonAndPhone = if (tempPhone.isEmpty()) { + failedReason + } else { +// "${failedReason};乘客:${tempPhone}" + "${failedReason}${StringUtils.getString(R.string.module_och_passenger)}${tempPhone}" + } + saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, V2XMsg( + EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.poiType, + reaseonAndPhone, + EventTypeEnumNew.TYPE_ABNORMAL_VERIFICATION.tts, + "" + ) + ) + ) + } + + /** + * 验票成功 + * 1、本地核销 + * 2、云端核销 + */ + private fun writeOffSuccess(ticketSize: Int, phone: String, orderNo: String, ticketName: String, businessTime: Long) { + + // 发送乘客屏 通过蓝牙告知小程序 为0时是 安全员小程序核销的 + if (businessTime > 0) { + LanSocketManager.sendMsgToClient( + WriteOffResultMsg( + code = 0,// 00成功 + phone = phone, + orderNo = orderNo, + businessTime = businessTime, + LineManager.lineInfos?.lineId ?: 0L, + LineManager.getStations()?.first?.siteId?.toLong() ?: 0L + ) + ) + } + BizLoopManager.runInIoThread { selectWriteOffCount() } + + ShuttleVoiceManager.writeOffCount(ticketSize) + + var tempPhone = phone + if (tempPhone.length > 8) { + //截取电话号码前三位 + val phoneNumPre = tempPhone.substring(0, 3) + //截取电话号码后四位 + val phoneNumFix = tempPhone.substring(7) + tempPhone = "$phoneNumPre****$phoneNumFix" + } +// val content = "${ticketSize}张 $ticketName $tempPhone" + val content = "${ticketSize}${StringUtils.getString(R.string.module_och_piece)} $ticketName $tempPhone" + saveMsgBox(MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + EventTypeEnumNew.TYPE_VERIFICATION_SUCCESSFUL.poiType, + content, + EventTypeEnumNew.TYPE_VERIFICATION_SUCCESSFUL.tts, + "" + ) + ) + ) + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/RepositoryManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/RepositoryManager.kt new file mode 100644 index 0000000000..975c36dfd6 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/RepositoryManager.kt @@ -0,0 +1,250 @@ +package com.mogo.och.unmanned.repository + +import android.content.Context +import com.mogo.commons.env.Project +import com.mogo.commons.env.ProjectUtils +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.unmanned.bean.WaitUploadLine +import com.mogo.och.unmanned.bean.WriteOffPassenger +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.db.repository.EventDb +import com.mogo.och.unmanned.repository.line.ILineRepository +import com.mogo.och.unmanned.repository.line.impl.NormalRepository +import com.mogo.och.unmanned.repository.line.impl.WeaknetRepository +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse +import com.mogo.och.unmanned.repository.writeoff.IWriteOffRepository +import com.mogo.och.unmanned.repository.writeoff.impl.WriteOffCacheRepository +import com.mogo.och.unmanned.repository.writeoff.impl.WriteOffNormallRepository +import io.reactivex.Observable + +object RepositoryManager { + + private val TAG = "${M_BUS}RepositoryManager" + private var lineRepository: ILineRepository? = null + get() { + if (field == null) { + when (ProjectUtils.getProjectType()) { + Project.SAAS -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = WeaknetRepository() + CallerLogger.d(TAG, "saas shuttle 支持db") + } else if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + field = WeaknetRepository() + CallerLogger.d(TAG, "saas scheduled 支持db") + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = WeaknetRepository() + CallerLogger.d(TAG, "saas bus 支持db") + } + } + + Project.DALI -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = WeaknetRepository() + CallerLogger.d(TAG, "dali shuttle 支持db") + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = NormalRepository() + CallerLogger.d(TAG, "dali bus 不支持db") + } + } + + Project.MOGO -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = NormalRepository() + CallerLogger.d(TAG, "mogo shuttle 不支持db") + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = NormalRepository() + CallerLogger.d(TAG, "mogo bus 不支持db") + } + } + + else -> {} + } + } + return field + } + + private var writeOffRepository: IWriteOffRepository? = null + get() { + if (field == null) { + when (ProjectUtils.getProjectType()) { + Project.SAAS -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = WriteOffCacheRepository() + CallerLogger.d(TAG, "saas shuttle 核销缓存") + } else if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + field = WriteOffCacheRepository() + CallerLogger.d(TAG, "saas sceduletd 核销缓存") + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = WriteOffCacheRepository() + CallerLogger.d(TAG, "saas bus 核销缓存") + } + } + + Project.DALI -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = WriteOffNormallRepository() + CallerLogger.d(TAG, "dali shuttle 不支持核销缓存") + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = WriteOffNormallRepository() + CallerLogger.d(TAG, "dali bus 不支持核销缓存") + } + } + + else -> {} + } + } + return field + } + + fun release() { + closeDb() + } + + fun loadCurrentTaskInfo(): Observable? { + return lineRepository?.loadCurrentTaskInfo() + } + + fun queryCanUseLine(): Observable?>? { + return lineRepository?.queryCanUseLine() + } + + fun queryCanUserTask(lineId: Long): Observable?>? { + return lineRepository?.queryCanUserTask(lineId) + } + + fun startTask(shiftsId: Long, taskId: Long, lineId: Long, taskTime: Long, lineName: String): Observable? { + return lineRepository?.startTask(shiftsId, taskId, lineId, taskTime, lineName) + } + + fun leaveStation( + seq: Int, siteId: Long, shiftsId: Long, taskId: Long, lineId: Long, taskStartTime: Long, taskDate: Long + ): Observable? { + return lineRepository?.leaveStation(seq, siteId, shiftsId, taskId, lineId, taskStartTime, taskDate) + } + + fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable? { + return lineRepository?.arriveStation(seq, siteId, taskId) + } + + fun endTask(shiftsId: Long, taskId: Long): Observable? { + return lineRepository?.endTask(shiftsId, taskId) + } + + + fun endTaskByOther(taskId: Long) { + lineRepository?.endTaskByOther(taskId) + } + + fun haveRunningTask(): Boolean { + return lineRepository?.haveRunningTask() ?: false + } + + + fun haveDataWaitSyn(): Boolean { + if (ProjectUtils.isSaas() && AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + EventDb.queryWaitUpdateEvent()?.let { + return it.isNotEmpty() + } + } + return false + } + + fun supportDb(): Boolean { + if (ProjectUtils.isSaas() || (ProjectUtils.isDali() && AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode))) { + return true + } + return false + } + + fun supportWriteOff(): Boolean { + if (ProjectUtils.isSaas() || (ProjectUtils.isDali())) { + return true + } + return false + } + + fun supportWriteOffDb(): Boolean { + if (supportWriteOff()) { + return ProjectUtils.isSaas() + } + return false + } + + fun queryCarExecutableTaskList( + ochCommonServiceCallback: OchCommonServiceCallback + ) { + if (lineRepository is WeaknetRepository) { + lineRepository?.queryCarExecutableTaskList(ochCommonServiceCallback) + } + } + + fun queryPointFromNet(lines: MutableList): Observable>? { + if (lineRepository is WeaknetRepository) { + return lineRepository?.queryPointsByLineIds(lines) + } + return null + } + + fun reportCabinEvent( + context: Context?, + data: ShuttleEventRequest?, + callback: OchCommonServiceCallback? + ) { + if (lineRepository is WeaknetRepository) { + lineRepository?.reportCabinEvent(context, data, callback) + } + } + + fun queryWriteoffCount(context: Context, taskId: Long, siteId: Long): Observable? { + return writeOffRepository?.queryWriteoffCount(context, taskId, siteId) + } + + fun writeOff(writeOffDetialMsg: WriteOffDetialMsg): Observable? { + return writeOffRepository?.writeOffEvent(writeOffDetialMsg) + } + + fun queryWaitUploadData(): Observable>? { + return writeOffRepository?.queryWaitUploadData() + } + + + fun canCanEndTask(taskId: Long): Boolean { + return writeOffRepository?.canCanEndTask(taskId) ?: true + } + + /** + * 安全员小程序核销成功的用户计数用 + */ + fun saveWriteOff4Socket(passenger: WriteOffPassenger) { + BizLoopManager.runInIoThread { + writeOffRepository?.writeOffEvent4Socket(passenger) + } + } + + fun closeDb() { + if (supportDb()) { + MyDataBase.instance?.close() + CallerLogger.d(TAG, "关闭数据库") + MyDataBase.instance = null + CallerLogger.d(TAG, "重置数据库") + lineRepository?.release() + lineRepository = null + writeOffRepository?.release() + writeOffRepository = null + CallerLogger.d(TAG, "重置 repository") + } + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/IDbRepository.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/IDbRepository.kt new file mode 100644 index 0000000000..7c951a269c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/IDbRepository.kt @@ -0,0 +1,9 @@ +package com.mogo.och.unmanned.repository.db + +interface IDbRepository { + fun register() { + MyDataBase.instance?.register(this) + } + + fun release() +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/MyDataBase.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/MyDataBase.kt new file mode 100644 index 0000000000..e9b4019dfa --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/MyDataBase.kt @@ -0,0 +1,201 @@ +package com.mogo.och.unmanned.repository.db + +import android.os.Environment +import androidx.room.Database +import androidx.room.Room +import androidx.room.RoomDatabase +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.env.Project +import com.mogo.commons.env.ProjectUtils +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.util.FileUtils +import com.mogo.och.unmanned.repository.db.bean.ContrailDataBean +import com.mogo.och.unmanned.repository.db.bean.EventDataBean +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.PointDataBean +import com.mogo.och.unmanned.repository.db.bean.SiteDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean +import com.mogo.och.unmanned.repository.db.bean.WriteOffDataBean +import com.mogo.och.unmanned.repository.db.dao.ContrailDataDao +import com.mogo.och.unmanned.repository.db.dao.EventDataDao +import com.mogo.och.unmanned.repository.db.dao.LineDataDao +import com.mogo.och.unmanned.repository.db.dao.PointDataDao +import com.mogo.och.unmanned.repository.db.dao.SiteDataDao +import com.mogo.och.unmanned.repository.db.dao.TaskDataDao +import com.mogo.och.unmanned.repository.db.dao.TaskSiteDataDao +import com.mogo.och.unmanned.repository.db.dao.WriteOffDataDao +import java.io.File +import java.util.concurrent.Executors + +//注解Database告诉系统这是Room数据库对象 +//entities指定该数据库有哪些表,多张表就逗号分隔 +//version指定数据库版本号,升级时需要用到 +//数据库继承自RoomDatabase +@Database(entities = [ContrailDataBean::class, LineDataBean::class, + SiteDataBean::class, TaskDataBean::class, TaskSiteDataBean::class, + EventDataBean::class, WriteOffDataBean::class, PointDataBean::class +], version = 8) +abstract class MyDataBase : RoomDatabase() { + + private val dbRepositorys = mutableListOf() + + override fun close() { + super.close() + dbRepositorys.forEach { + it.release() + } + dbRepositorys.clear() + } + + fun register(iDbRepository: IDbRepository) { + dbRepositorys.add(iDbRepository) + } + + abstract val contrailDataDao: ContrailDataDao? + abstract val eventDataDao: EventDataDao? + abstract val lineDataDao: LineDataDao? + abstract val pointDataDao: PointDataDao? + abstract val siteDataDao: SiteDataDao? + abstract val taskDataDao: TaskDataDao? + abstract val taskSiteDataDao: TaskSiteDataDao? + abstract val writeOffDataDao: WriteOffDataDao? + + companion object { + + + private val TAG = "MyDataBase" + + + private val MIGRATION_1_2 = object : Migration(1, 2) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE ${EventDataBean.tableName} ADD COLUMN driver_id INTEGER"); + } + } + private val MIGRATION_2_3 = object : Migration(2, 3) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE ${SiteDataBean.tableName} ADD COLUMN videoList TEXT"); + database.execSQL("ALTER TABLE ${TaskSiteDataBean.tableName} ADD COLUMN videoList TEXT"); + } + } + private val MIGRATION_3_4 = object : Migration(3, 4) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE ${EventDataBean.tableName} ADD COLUMN msg_id TEXT") + database.execSQL("ALTER TABLE ${EventDataBean.tableName} ADD COLUMN update_time INTEGER") + } + } + + private val MIGRATION_4_5 = object : Migration(4, 5) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("CREATE TABLE IF NOT EXISTS `${WriteOffDataBean.tableName}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `msg_id` TEXT, `expiry_time` INTEGER, `booking_time` INTEGER, `type` INTEGER, `task_id` INTEGER, `line_id` INTEGER, `site_id` INTEGER, `driver_id` INTEGER, `available_times` INTEGER, `order_no` TEXT, `uid` TEXT, `seq` TEXT, `business_time` INTEGER, `tick_size` INTEGER, `tick_name` TEXT, `event_save_time` INTEGER NOT NULL, `update_status` INTEGER NOT NULL, `update_time` INTEGER)") + database.execSQL("CREATE INDEX `index_writeoff_data_table_event_save_time` ON `writeoff_data_table` (`event_save_time`)") + } + } + + private val MIGRATION_5_6 = object : Migration(5, 6) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE ${EventDataBean.tableName} ADD COLUMN task_date INTEGER") + database.execSQL("ALTER TABLE ${EventDataBean.tableName} ADD COLUMN shifts_id INTEGER") + database.execSQL("ALTER TABLE ${WriteOffDataBean.tableName} ADD COLUMN task_date INTEGER") + database.execSQL("ALTER TABLE ${WriteOffDataBean.tableName} ADD COLUMN shifts_id INTEGER") + database.execSQL("ALTER TABLE ${TaskDataBean.tableName} ADD COLUMN shifts_id INTEGER") + database.execSQL("ALTER TABLE ${TaskSiteDataBean.tableName} ADD COLUMN shifts_id INTEGER") + } + } + + private val MIGRATION_6_7 = object : Migration(6, 7) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("CREATE TABLE IF NOT EXISTS `${PointDataBean.tableName}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `line_id` INTEGER, `contrail_id` INTEGER, `site_id` INTEGER, `md5` TEXT, `seq` INTEGER, `point_type` INTEGER, `longitude` REAL, `latitude` REAL, `sub_seq` INTEGER)") + database.execSQL("ALTER TABLE ${ContrailDataBean.tableName} ADD COLUMN contrail_id INTEGER") + database.execSQL("ALTER TABLE ${ContrailDataBean.tableName} ADD COLUMN source INTEGER") + } + } + private val MIGRATION_7_8 = object : Migration(7, 8) { + override fun migrate(db: SupportSQLiteDatabase) { + // 获取当前数据库文件名(通过database路径解析) + CallerLogger.d(TAG, "数据库路径:${db.path ?: "错误"}") + val dbPath = db.path ?: return + val dbFileName = dbPath.substringAfterLast(File.separator) + // 仅当数据库是shuttle_db时,执行新增tag字段操作 + if (dbFileName == "shuttle_db") { + // 新增tag字段:int类型,非空,默认值0 + db.execSQL("ALTER TABLE ${SiteDataBean.tableName} ADD COLUMN tag INTEGER NOT NULL DEFAULT 0") + db.execSQL("ALTER TABLE ${TaskSiteDataBean.tableName} ADD COLUMN tag INTEGER NOT NULL DEFAULT 0") + CallerLogger.d(TAG, "shuttle_db:给${SiteDataBean.tableName}、${TaskSiteDataBean.tableName}新增tag字段成功") + } else { + CallerLogger.d(TAG, "非shuttle_db,跳过tag字段新增") + } + } + } + + + fun getDBName(): MyDataBase { + val roomName = when (ProjectUtils.getProjectType()) { + Project.SAAS -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + "shuttle_db" + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + "saas_bus_db" + } else if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + "saas_scheduled_db" + } else { + FunctionBuildConfig.appIdentityMode + } + } + + Project.DALI -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + "dali_shuttle_db" + } else { + FunctionBuildConfig.appIdentityMode + } + } + + else -> { + FunctionBuildConfig.appIdentityMode + } + } + + FileUtils.createOrExistsDir(ROOT_PATH) + + val dbFile = AbsMogoApplication.getApp().getDatabasePath(roomName) + + val oldDbFile = File(ROOT_PATH) + oldDbFile.listFiles()?.forEach { + FileUtils.moveFile(it, File(dbFile.parent + File.separator + it.name), null) + } + + FileUtils.deleteFilesInDir(ROOT_PATH) + + return Room.databaseBuilder( + AbsMogoApplication.getApp()!!.applicationContext, + MyDataBase::class.java, + dbFile.path + ) + .addMigrations(MIGRATION_1_2) + .addMigrations(MIGRATION_2_3) + .addMigrations(MIGRATION_3_4) + .addMigrations(MIGRATION_4_5) + .addMigrations(MIGRATION_5_6) + .addMigrations(MIGRATION_6_7) + .addMigrations(MIGRATION_7_8) + .fallbackToDestructiveMigration() + .setQueryCallback({ sqlQuery, bindArgs -> CallerLogger.d(TAG, "sql:$sqlQuery--->参数:$bindArgs") }, Executors.newSingleThreadExecutor()) + .build() + } + + val ROOT_PATH = Environment.getExternalStorageDirectory().absolutePath + File.separator + "Mogo" + File.separator + "APP_cache" + File.separator //程序外部存储跟目录 + + var instance: MyDataBase? = getDBName() + get() { + if (field == null) { + field = getDBName() + } + return field + } + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/ContrailDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/ContrailDataBean.kt new file mode 100644 index 0000000000..e32263351a --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/ContrailDataBean.kt @@ -0,0 +1,80 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +/** + * 启动自驾使用的轨迹信息 + */ +@Entity(tableName = ContrailDataBean.tableName) +data class ContrailDataBean( + + @PrimaryKey(autoGenerate = true) var id: Int = 0, + + /** + * 线路id + */ + @ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER, index = true) + var lineId: Long? = null, + + /** + * 轨迹id + */ + @ColumnInfo(name = "contrail_id", typeAffinity = ColumnInfo.INTEGER) + var contrailId: Long? = null, + + /** + * csv格式的轨迹文件 + */ + @ColumnInfo(name = "csv_file_url", typeAffinity = ColumnInfo.TEXT) + var csvFileUrl: String? = null, + + /** + * csv_file_url 文件的md5值 + */ + @ColumnInfo(name = "csv_file_md5", typeAffinity = ColumnInfo.TEXT) + var csvFileMd5: String? = null, + + /** + * txt格式的轨迹文件 + */ + @ColumnInfo(name = "txt_file_url", typeAffinity = ColumnInfo.TEXT) + var txtFileUrl: String? = null, + + /** + * txt文件的md5 + */ + @ColumnInfo(name = "txt_file_md5", typeAffinity = ColumnInfo.TEXT) + var txtFileMd5: String? = null, + + /** + * 文件的保存时间 + */ + @ColumnInfo(name = "contrail_save_time", typeAffinity = ColumnInfo.INTEGER) + var contrailSaveTime: Long? = null, + + /** + * 前几个字符拼接后做md5的值 + */ + @ColumnInfo(name = "md5", typeAffinity = ColumnInfo.TEXT, index = true) + var md5: String? = null, + + /** + * 轨迹id + */ + @ColumnInfo(name = "source", typeAffinity = ColumnInfo.INTEGER) + var source: Int? = null, + + + ) { + companion object { + const val tableName: String = "contrail_data_table" + const val SOURCETYPEROUTING = 2 + } + + override fun toString(): String { + return "ContrailDataBean(lineId=$lineId, csvFileUrl=$csvFileUrl, csvFileMd5=$csvFileMd5, txtFileUrl=$txtFileUrl, txtFileMd5=$txtFileMd5, contrailSaveTime=$contrailSaveTime)" + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/EventDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/EventDataBean.kt new file mode 100644 index 0000000000..b4034e96f5 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/EventDataBean.kt @@ -0,0 +1,119 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +/** + * 上报给服务器端的 选择线路、滑动出发、进站 完成线路的对象 + */ +@Entity(tableName = EventDataBean.tableName) +data class EventDataBean( + + @PrimaryKey(autoGenerate = true) var id: Int = 0, + + /** + * 事件类型 + */ + @ColumnInfo(name = "event_type", typeAffinity = ColumnInfo.TEXT) + var eventType: String? = null, + + /** + * 生成任务的模板id + */ + @ColumnInfo(name = "shifts_id", typeAffinity = ColumnInfo.INTEGER) + var shiftsId: Long? = null, + + /** + * 任务id、模板id + */ + @ColumnInfo(name = "lineId", typeAffinity = ColumnInfo.INTEGER) + var lineId: Long? = null, + + /** + * 模板发生日期 + */ + @ColumnInfo(name = "task_date", typeAffinity = ColumnInfo.INTEGER) + var taskDate: Long? = null, + + + /** + * 任务id + */ + @ColumnInfo(name = "lineName", typeAffinity = ColumnInfo.TEXT) + var lineName: String? = null, + + + /** + * 任务id + */ + @ColumnInfo(name = "task_id", typeAffinity = ColumnInfo.INTEGER) + var taskId: Long? = null, + + /** + * 任务id + */ + @ColumnInfo(name = "task_start_time", typeAffinity = ColumnInfo.INTEGER) + var taskStartTime: 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 = "driver_id", typeAffinity = ColumnInfo.INTEGER) + var driverId: Long? = null, + + /** + * 存储此条数据时时间戳 + */ + @ColumnInfo(name = "event_save_time", typeAffinity = ColumnInfo.INTEGER, index = true) + val eventSaveTime: Long = System.currentTimeMillis(), + + @ColumnInfo(name = "update_status", typeAffinity = ColumnInfo.INTEGER) + var updateStatus: Int = 0, + + @ColumnInfo(name = "msg_id", typeAffinity = ColumnInfo.TEXT) + var msgId: String? = "", + + @ColumnInfo(name = "update_time", typeAffinity = ColumnInfo.INTEGER) + var upDateTime: Long? = 0L, + + ) { + companion object { + const val tableName: String = "event_data_table" + + const val TaskStart = "TaskStart" + const val TaskArriveSite = "TaskArriveSite" + const val TaskLeaveSite = "TaskLeaveSite" + const val TaskEnd = "TaskEnd" + + + const val notUpdate = 0 + const val updating = 1 + const val updated = 2 + + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/LineDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/LineDataBean.kt new file mode 100644 index 0000000000..d9af1e7acf --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/LineDataBean.kt @@ -0,0 +1,71 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import com.google.gson.annotations.SerializedName + +@Entity(tableName = LineDataBean.tableName) +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) + @SerializedName("name", alternate = ["lineName"]) + var lineName: String? = null, + + /** + * 终点站名称 + */ + @ColumnInfo(name = "end_station_name", typeAffinity = ColumnInfo.TEXT) + @SerializedName("endSiteName") + var endStationName: String? = null, + + /** + * 存储此条数据时时间戳 + */ + @ColumnInfo(name = "line_get_time", typeAffinity = ColumnInfo.INTEGER) + val linegetTime: Long = System.currentTimeMillis(), +) { + companion object { + const val tableName: String = "line_data_table" + } + + + fun getLineIdAndName(function: (lineId: Long, lineName: String) -> Unit) { + lineId?.let { id -> + lineName?.let { name -> + function(id, name) + } + } + } + + 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 + } + + override fun hashCode(): Int { + var result = lineId?.hashCode() ?: 0 + result = 31 * result + (lineName?.hashCode() ?: 0) + return result + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/PointDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/PointDataBean.kt new file mode 100644 index 0000000000..346af6ac44 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/PointDataBean.kt @@ -0,0 +1,86 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import com.mogo.och.data.bean.BusStationBean + +@Entity(tableName = PointDataBean.tableName) +data class PointDataBean( + + @PrimaryKey(autoGenerate = true) var id: Int = 0, + + /** + * 点所属线路Id + */ + @ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER) + var lineId: Long? = null, + + /** + * 轨迹id + */ + @ColumnInfo(name = "contrail_id", typeAffinity = ColumnInfo.INTEGER) + var contrailId: Long? = null, + + /** + * A--B--C--D + * A--B 的途径点 siteId = B.id + * B--C 的途径点 siteId = C.id + * C--D 的途径点 siteId = D.id + */ + @ColumnInfo(name = "site_id", typeAffinity = ColumnInfo.INTEGER) + var siteId: Long? = null, + + /** + * ContrailDataBean 表格中的md5值 + */ + @ColumnInfo(name = "md5", typeAffinity = ColumnInfo.TEXT) + var md5: String? = null, + + + /** + * 排队组 + */ + @ColumnInfo(name = "seq", typeAffinity = ColumnInfo.INTEGER) + var seq: Int? = null, + + /** + * 点的类型 + */ + @ColumnInfo(name = "point_type", typeAffinity = ColumnInfo.INTEGER) + var pointType: Int? = null, + + /** + * 高精坐标 + */ + @ColumnInfo(name = "longitude", typeAffinity = ColumnInfo.REAL) + var longitude: Double? = null, + + /** + * 高精坐标 + */ + @ColumnInfo(name = "latitude", typeAffinity = ColumnInfo.REAL) + var latitude: Double? = null, + + /** + * 组内排序 + */ + @ColumnInfo(name = "sub_seq", typeAffinity = ColumnInfo.INTEGER) + var subSeq: Int? = null, + + ) { + fun toStation(): BusStationBean { + val temp = BusStationBean() + temp.lat = latitude ?: 0.0 + temp.lon = longitude ?: 0.0 + temp.pointType = pointType ?: pointTypePass + temp.isLeaving = true + return temp + } + + companion object { + const val tableName = "point_data_table" + const val pointTypePass = 1 + const val pointTypeBlack = 2 + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/SiteDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/SiteDataBean.kt new file mode 100644 index 0000000000..c911bccc4d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/SiteDataBean.kt @@ -0,0 +1,127 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.Ignore +import androidx.room.PrimaryKey +import com.mogo.och.data.bean.SiteIntroduce + +@Entity(tableName = SiteDataBean.tableName) +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, + + /** + * 站点视频 + */ + @ColumnInfo(name = "videoList", typeAffinity = ColumnInfo.TEXT) + var videoListDB: String? = null, + + /** + * 站点标志 0:未赋值/默认值,与1结果一致 1:正常停靠 2:临时不停靠 + */ + @ColumnInfo(name = "tag", typeAffinity = ColumnInfo.INTEGER, defaultValue = "0") + var tag: Int = 0, + + @Ignore + var videoList: MutableList? = null +) { + companion object { + const val tableName = "site_data_table" + const val mediaTypeVideo = 1 + } + + 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, videoList=$videoListDB, tag=$tag)" + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as SiteDataBean + + if (siteId != other.siteId) return false + if (lineId != other.lineId) return false + + return true + } + + override fun hashCode(): Int { + var result = siteId?.hashCode() ?: 0 + result = 31 * result + (lineId?.hashCode() ?: 0) + return result + } + + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/TaskDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/TaskDataBean.kt new file mode 100644 index 0000000000..64213296c3 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/TaskDataBean.kt @@ -0,0 +1,120 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey +import com.google.gson.annotations.SerializedName +import com.mogo.och.unmanned.repository.RepositoryManager + +@Entity(tableName = TaskDataBean.tableName) +data class TaskDataBean( + + @PrimaryKey(autoGenerate = true) + @SerializedName("idtemp") + var id: Int = 0, + + /** + * 生成任务的模板id + */ + @ColumnInfo(name = "shifts_id", typeAffinity = ColumnInfo.INTEGER) + var shiftsId: Long? = null, + + /** + * 任务id + */ + @ColumnInfo(name = "task_id", typeAffinity = ColumnInfo.INTEGER, index = true) + @SerializedName("id") + 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 tableName: String = "task_data_table" + + const val unUse = 0L + const val useing = 1L + const val used = 2L + + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as TaskDataBean + + if (taskId != other.taskId) return false + if (lineId != other.lineId) return false + if (shiftsId != other.shiftsId) return false + + return true + } + + override fun hashCode(): Int { + var result = taskId?.hashCode() ?: 0 + result = 31 * result + (lineId?.hashCode() ?: 0) + return result + } + + fun getLineIdAndName(function: (shiftsId: Long, taskId: Long, taskTime: Long, taskDate: Long) -> Unit) { + if (RepositoryManager.supportDb()) { + taskId?.let { id -> + taskStartTime?.let { time -> + taskDate?.let { date -> + shiftsId?.let { shiftsId -> + function(shiftsId, id, time, date) + } + } + } + } + } else { + taskId?.let { id -> + taskStartTime?.let { time -> + function(shiftsId ?: 0, id, time, taskDate ?: System.currentTimeMillis()) + } + } + } + + } + + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/TaskSiteDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/TaskSiteDataBean.kt new file mode 100644 index 0000000000..c5dfbc66cc --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/TaskSiteDataBean.kt @@ -0,0 +1,182 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(tableName = TaskSiteDataBean.tableName) +data class TaskSiteDataBean( + + @PrimaryKey(autoGenerate = true) var id: Int = 0, + + /** + * 任务id + */ + @ColumnInfo(name = "task_id", typeAffinity = ColumnInfo.INTEGER) + var taskId: Long? = null, + + /** + * 生成任务的模板id + */ + @ColumnInfo(name = "shifts_id", typeAffinity = ColumnInfo.INTEGER) + var shiftsId: Long? = null, + + /** + * 线路id + */ + @ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER) + var lineId: Long? = null, + + /** + * 站点id + */ + @ColumnInfo(name = "site_id", typeAffinity = ColumnInfo.INTEGER) + var siteId: Long? = null, + + /** + * 线路名称 删除线路 特殊情况下要展示线路的冗余 + */ + @ColumnInfo(name = "line_name", typeAffinity = ColumnInfo.TEXT) + var lineName: String? = 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, + + + /** + * 任务保存到数据库的时间 用来第二天删除前几天的任务 + */ + @ColumnInfo(name = "event_save_time", typeAffinity = ColumnInfo.INTEGER) + var eventSaveTime: Long = System.currentTimeMillis(), + + /** + * 站点视频 + */ + @ColumnInfo(name = "videoList", typeAffinity = ColumnInfo.TEXT) + var videoList: String? = null, + + /** + * 站点标志 0:未赋值/默认值,与1结果一致 1:正常停靠 2:临时不停靠 + */ + @ColumnInfo(name = "tag", typeAffinity = ColumnInfo.INTEGER, defaultValue = "0") + var tag: Int = 0, +) { + companion object { + /** + * 开始任务 并把第一站置为 2 当前站 + */ + fun toTaskSiteDatas(querySites: List, shiftsId: Long, taskId: Long, lineName: String): MutableList { + val result = mutableListOf() + var temp: TaskSiteDataBean? = null + querySites.forEach { + temp = TaskSiteDataBean() + temp?.taskId = taskId + temp?.shiftsId = shiftsId + 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 = drivingStatusCurrent + } else { + temp?.drivingStatus = drivingStatusNotArrived + } + temp?.leaving = false + temp?.introduction = it.introduction + temp?.isPlayTts = it.isPlayTts + temp?.videoList = it.videoListDB + temp?.tag = it.tag + result.add(temp!!) + } + return result + } + + const val tableName: 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未到站 + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/WriteOffDataBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/WriteOffDataBean.kt new file mode 100644 index 0000000000..663155f5fe --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/bean/WriteOffDataBean.kt @@ -0,0 +1,148 @@ +package com.mogo.och.unmanned.repository.db.bean + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +/** + * 上报给服务器端的 选择线路、滑动出发、进站 完成线路的对象 + */ +@Entity(tableName = WriteOffDataBean.tableName) +data class WriteOffDataBean( + + @PrimaryKey(autoGenerate = true) var id: Int = 0, + + /** + * 二维码有效时间 时间戳 有效时间1分钟 + */ + @ColumnInfo(name = "msg_id", typeAffinity = ColumnInfo.TEXT) + var msgId: String? = null, + + /** + * 二维码有效时间 时间戳 有效时间1分钟 + */ + @ColumnInfo(name = "expiry_time", typeAffinity = ColumnInfo.INTEGER) + var expiryTime: Long? = null, + + /** + * 乘车日期 + */ + @ColumnInfo(name = "booking_time", typeAffinity = ColumnInfo.INTEGER) + var bookingTime: Long? = null, + + /** + * 校验接驳还是公交 shuttle bus + */ + @ColumnInfo(name = "type", typeAffinity = ColumnInfo.INTEGER) + var type: Int? = null, + + + /** + * 生成任务的模板id + */ + @ColumnInfo(name = "shifts_id", typeAffinity = ColumnInfo.INTEGER) + var shiftsId: Long? = null, + + /** + * 当前的任务id、模板id + */ + @ColumnInfo(name = "task_id", typeAffinity = ColumnInfo.INTEGER) + var taskId: Long? = null, + + /** + * 模板发生日期 + */ + @ColumnInfo(name = "task_date", typeAffinity = ColumnInfo.INTEGER) + var taskDate: Long? = null, + + + /** + * 校验线路Id + */ + @ColumnInfo(name = "line_id", typeAffinity = ColumnInfo.INTEGER) + var lineId: Long? = null, + + /** + * 校验站点Id + */ + @ColumnInfo(name = "site_id", typeAffinity = ColumnInfo.INTEGER) + var siteId: Long? = null, + + /** + * 司机id + */ + @ColumnInfo(name = "driver_id", typeAffinity = ColumnInfo.INTEGER) + var driverId: Long? = null, + + /** + * 剩余核销次数>0 + */ + @ColumnInfo(name = "available_times", typeAffinity = ColumnInfo.INTEGER) + var availableTimes: Int? = null, + + /** + * 订单号 + */ + @ColumnInfo(name = "order_no", typeAffinity = ColumnInfo.TEXT) + var orderNo: String? = null, + + /** + * uid + */ + @ColumnInfo(name = "uid", typeAffinity = ColumnInfo.TEXT) + var uid: String? = null, + + /** + * 用户手机号 + */ + @ColumnInfo(name = "seq", typeAffinity = ColumnInfo.TEXT) + var phone: String? = null, + + /** + * 业务发生的时间 + */ + @ColumnInfo(name = "business_time", typeAffinity = ColumnInfo.INTEGER) + var businessTime: Long? = null, + + /** + * 票里人数 + */ + @ColumnInfo(name = "tick_size", typeAffinity = ColumnInfo.INTEGER) + var ticketSize: Int? = null, + + /** + * 票的类型 + */ + @ColumnInfo(name = "tick_name", typeAffinity = ColumnInfo.TEXT) + var ticketName: String? = null, + + /** + * 存储此条数据时时间戳 + */ + @ColumnInfo(name = "event_save_time", typeAffinity = ColumnInfo.INTEGER, index = true) + val eventSaveTime: Long = System.currentTimeMillis(), + + @ColumnInfo(name = "update_status", typeAffinity = ColumnInfo.INTEGER) + var updateStatus: Int = notUpdate, + + @ColumnInfo(name = "update_time", typeAffinity = ColumnInfo.INTEGER) + var upDateTime: Long? = 0L, + + + ) { + companion object { + const val tableName: String = "writeoff_data_table" + + // 没有上传 + const val notUpdate = 0 + + // 上传中 + const val updating = 1 + + // 已上传 + const val updated = 2 + + const val daliXiaoChengXu = "ehsafety" + const val saasXiaoChengXu = "mogogosafety" + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/ContrailDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/ContrailDataDao.kt new file mode 100644 index 0000000000..9a0071e543 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/ContrailDataDao.kt @@ -0,0 +1,45 @@ +package com.mogo.och.unmanned.repository.db.dao + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import com.mogo.och.unmanned.repository.db.bean.ContrailDataBean + +@Dao +interface ContrailDataDao { + + //插入轨迹信息 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg contrailDataBean: ContrailDataBean) + + @Query("UPDATE ${ContrailDataBean.tableName} SET csv_file_url = :csv_file_url ,csv_file_md5 = :csv_file_md5 ,txt_file_url = :txt_file_url " + + ",txt_file_md5 = :txt_file_md5 ,contrail_save_time = :contrail_save_time,md5 = :md5 WHERE id = :id") + fun update(csv_file_url: String,csv_file_md5: String,txt_file_url: String,txt_file_md5: String,contrail_save_time: Long,md5: String,id:Int) + + // 线路删除时同步删除所属轨迹信息 + @Query("DELETE FROM ${ContrailDataBean.tableName} WHERE line_id = :lineId") + fun deleteByLineId(lineId: Long) + + //查询线路对应的轨迹信息 + @Query("SELECT * FROM ${ContrailDataBean.tableName} WHERE line_id = :lineId") + fun queryContrailByLineId(lineId:Long): List? + + //查询线路对应的轨迹信息 + @Query("SELECT * FROM ${ContrailDataBean.tableName} WHERE md5 = :md5") + fun queryContrailByMd5(md5:String): List? + + //查询线路对应的轨迹信息 只要一个结果 + fun queryContrailByLineIdOne(lineId: Long): ContrailDataBean?{ + val queryContrailByLineId = queryContrailByLineId(lineId) + return if(queryContrailByLineId.isNullOrEmpty()){ + null + }else{ + queryContrailByLineId.first() + } + } + @Query("UPDATE ${ContrailDataBean.tableName} SET contrail_id = :contrailId ,source = :source WHERE line_id = :lineId") + fun updateIdAndSource(contrailId: Long, source: Int, lineId: Long) + + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/EventDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/EventDataDao.kt new file mode 100644 index 0000000000..a6a3a8d477 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/EventDataDao.kt @@ -0,0 +1,43 @@ +package com.mogo.och.unmanned.repository.db.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.unmanned.repository.db.bean.EventDataBean +import io.reactivex.Observable + +@Dao +interface EventDataDao { + + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg eventDataBean: EventDataBean) + + //删除数据 + @Delete + fun delete(vararg eventDataBean: EventDataBean) + + @Query("UPDATE ${EventDataBean.tableName} SET update_status = :status,update_time = :currentTimeMillis WHERE id = :id") + fun updateUpdateSatus(id: Int, status: Int, currentTimeMillis: Long): Int + + + // 删除过时数据 + @Query("DELETE FROM ${EventDataBean.tableName} WHERE event_save_time < :zeroTime") + fun deleteObsoleteData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int + + @Query("SELECT * FROM ${EventDataBean.tableName} WHERE update_status = ${EventDataBean.notUpdate}") + fun queryEventByStatusWithPage(): List? + + @Query("SELECT count(1) FROM ${EventDataBean.tableName} WHERE update_status = ${EventDataBean.notUpdate}") + fun queryEventByStatusWithPageCount(): Int + + @Query("SELECT * FROM ${EventDataBean.tableName} WHERE update_status = ${EventDataBean.notUpdate} and event_save_time > :zeroTime GROUP by task_start_time") + fun queryWaitUploadInfo(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Observable?> + + @Query("SELECT * FROM ${EventDataBean.tableName} order by event_save_time LIMIT 5 OFFSET 0") + fun queryLastDataByWaritData(): List? + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/LineDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/LineDataDao.kt new file mode 100644 index 0000000000..38d661ddf0 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/LineDataDao.kt @@ -0,0 +1,45 @@ +package com.mogo.och.unmanned.repository.db.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.unmanned.repository.db.bean.LineDataBean +import io.reactivex.Observable + +@Dao +interface LineDataDao { + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg lineDataBean: LineDataBean) + + //删除数据 + @Delete + fun delete(vararg lineDataBean: LineDataBean) + + @Query("UPDATE ${LineDataBean.tableName} SET line_name = :lineName ,end_station_name = :endStationName WHERE id = :id") + fun updateInfo(lineName: String?, endStationName: String?, id: Long) + + // 删除过时数据 + @Query("DELETE FROM ${LineDataBean.tableName} WHERE line_get_time < :zeroTime") + fun deleteObsoleteData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int + + + //删除非昨天添加的数据 + @Query("DELETE FROM ${LineDataBean.tableName} WHERE line_get_time < :zeroTime") + fun deleteWeltData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int + + //查询当天插入的所有数据 + @Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime") + fun loadDataRx(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Observable?> + + //查询当天插入的所有数据 + @Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_get_time > :zeroTime") + fun loadData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List? + + @Query("SELECT * FROM ${LineDataBean.tableName} WHERE line_id = :lineId") + fun queryByLineId(lineId: Int): List? + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/PointDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/PointDataDao.kt new file mode 100644 index 0000000000..4612a68da1 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/PointDataDao.kt @@ -0,0 +1,39 @@ +package com.mogo.och.unmanned.repository.db.dao + +import androidx.room.Dao +import androidx.room.Delete +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import androidx.room.Transaction +import com.mogo.och.unmanned.repository.db.bean.PointDataBean + +@Dao +interface PointDataDao { + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg lineDataBean: PointDataBean) + + //插入数据 + @Transaction + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insertTra(vararg lineDataBean: PointDataBean) + + + //删除数据 + @Delete + fun delete(vararg lineDataBean: PointDataBean) + + + // 线路删除时同步删除所属轨迹信息 + @Transaction + @Query("DELETE FROM ${PointDataBean.tableName} WHERE line_id in (:lineId)") + fun deleteByLineIdTra(lineId: List) + + @Transaction + @Query("DELETE FROM ${PointDataBean.tableName} WHERE line_id in (:lineId)") + fun deleteByLineId(lineId: List) + + @Query("SELECT * FROM ${PointDataBean.tableName} WHERE line_id = :lineId") + fun queryPointByLineId(lineId: Long): List? +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/SiteDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/SiteDataDao.kt new file mode 100644 index 0000000000..2040bf0a79 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/SiteDataDao.kt @@ -0,0 +1,59 @@ +package com.mogo.och.unmanned.repository.db.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.unmanned.repository.db.bean.SiteDataBean + +@Dao +interface SiteDataDao { + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg lineDataBean: SiteDataBean) + + @Delete + fun deleteById(vararg siteDataBean: SiteDataBean) + + @Query("UPDATE ${SiteDataBean.tableName} SET site_id = :site_id ,line_id = :lineId,name = :name,name_kr = :nameKr,seq = :seq," + + "gcj_lon = :gcjLon,gcj_lat = :gcjLat,lon = :lon,lat = :lat,introduction = :introduction," + + "is_play_tts = :isPlayTts,md5 = :md5,videoList = :videoListDB,tag = :tag WHERE id = :id") + fun updateInfo(site_id: Long?, lineId: Long?, name: String?, nameKr: String?, seq: Int?, + gcjLon: Double?, gcjLat: Double?, lon: Double?, lat: Double?, introduction: String?, + isPlayTts: Boolean?, md5: String?, videoListDB: String?, tag: Int, id: Int + ) + + + // 线路删除时同步删除所属站点 + @Query("DELETE FROM ${SiteDataBean.tableName} WHERE line_id = :lineId") + fun deleteByLineId(lineId: Long) + + //查询线路对应的轨迹信息 + @Query("SELECT * FROM ${SiteDataBean.tableName} WHERE md5 = :md5") + fun querySitesByMd5(md5: String): List? + + //查询线路对应的轨迹信息 + @Query("SELECT * FROM ${SiteDataBean.tableName}") + fun queryAllSites(): List? + + + @Query("SELECT * FROM ${SiteDataBean.tableName} WHERE line_id = :lineId and site_id = :siteId") + fun querySitesByLineIdAndSiteId(lineId: Long, siteId: Long): List? + + @Query("SELECT * FROM ${SiteDataBean.tableName} WHERE line_id = :lineId order by seq") + fun querySitesByLineId(lineId: Long): List? + + @Query("SELECT * FROM ${SiteDataBean.tableName} GROUP by md5 HAVING count(1) > 1") + fun checkData(): List? + + fun querySiteByLineIdAndSiteId(lineId: Long, siteId: Long): SiteDataBean? { + val queryContrailByLineId = querySitesByLineIdAndSiteId(lineId, siteId) + return if (queryContrailByLineId.isNullOrEmpty()) { + null + } else { + queryContrailByLineId.first() + } + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/TaskDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/TaskDataDao.kt new file mode 100644 index 0000000000..8aa9e6c3d4 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/TaskDataDao.kt @@ -0,0 +1,89 @@ +package com.mogo.och.unmanned.repository.db.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.unmanned.repository.db.bean.TaskDataBean +import io.reactivex.Observable + +@Dao +interface TaskDataDao { + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg lineDataBean: TaskDataBean) + + //删除数据 + @Delete + fun delete(vararg lineDataBean: TaskDataBean) + + @Query("UPDATE ${TaskDataBean.tableName} SET start_time = :currentTimeMillis ,status = :useing WHERE id = :id") + fun updateStatus(currentTimeMillis: Long, useing: Long, id: Int) + + //删除非昨天添加的数据 + @Query("DELETE FROM ${TaskDataBean.tableName} WHERE task_get_time < :zeroTime") + fun deleteDataByZero(zeroTime: Long): Int + + @Query("UPDATE ${TaskDataBean.tableName} SET end_time = :endTime,status = ${TaskDataBean.used} WHERE task_id = :taskId") + fun endTask(taskId: Long, endTime: Long = DateTimeUtil.getCurrentTimeStamp()) + + //查询当天插入的所有数据 + @Query("SELECT * FROM ${TaskDataBean.tableName} WHERE task_get_time > :zeroTime") + fun loadAllData(zeroTime: Long): List? + + // 查询当天特定线路正在执行的任务 + @Query("SELECT * FROM ${TaskDataBean.tableName} WHERE task_get_time > :zeroTime and status = ${TaskDataBean.useing} and line_id = :lineId") + fun queryRunningTaskByLineId( + lineId: Long, + zeroTime: Long = DateTimeUtil.getCurrentDateZero() + ): List? + + // 查询当天特定线路正在执行的任务 + @Query("SELECT * FROM ${TaskDataBean.tableName} WHERE task_get_time > :zeroTime and status = ${TaskDataBean.useing}") + fun queryRunningTaskByStatus(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List? + + @Query("SELECT * FROM ${TaskDataBean.tableName} WHERE task_get_time > :zeroTime and status = ${TaskDataBean.unUse} and line_id = :lineId order by task_start_time") + fun queryUnuseTask( + lineId: Long, + zeroTime: Long = DateTimeUtil.getCurrentDateZero() + ): Observable?> + + @Query("DELETE FROM ${TaskDataBean.tableName} WHERE task_get_time > :zeroTime and line_id = :lineId") + fun deleteByLineId(lineId: Long, zeroTime: Long = DateTimeUtil.getCurrentDateZero()) + + @Query("SELECT * FROM ${TaskDataBean.tableName} WHERE line_id = :lineId and task_get_time > :zeroTime") + fun querySitesByLineId( + lineId: Long?, + zeroTime: Long = DateTimeUtil.getCurrentDateZero() + ): List? + + //查询线路对应的轨迹信息 + @Query("SELECT * FROM ${TaskDataBean.tableName} WHERE task_id = :taskId") + fun queryContrailByLineId(taskId: Long): List? + + //查询线路对应的轨迹信息 + @Query("SELECT * FROM ${TaskDataBean.tableName}") + fun queryAllTask(): List? + + + // 删除过时数据 + @Query("DELETE FROM ${TaskDataBean.tableName} WHERE task_get_time < :zeroTime") + fun deleteObsoleteData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int + + @Query("UPDATE ${TaskDataBean.tableName} SET shifts_id = 0 WHERE shifts_id is null") + fun setShiftsIdDetail() + + + //查询线路对应的轨迹信息 只要一个结果 + fun queryTaskByTaskIdOne(taskId: Long): TaskDataBean? { + val queryContrailByLineId = queryContrailByLineId(taskId) + return if (queryContrailByLineId.isNullOrEmpty()) { + null + } else { + queryContrailByLineId.first() + } + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/TaskSiteDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/TaskSiteDataDao.kt new file mode 100644 index 0000000000..29647a0bea --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/TaskSiteDataDao.kt @@ -0,0 +1,37 @@ +package com.mogo.och.unmanned.repository.db.dao + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean + +@Dao +interface TaskSiteDataDao { + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg lineDataBean: TaskSiteDataBean): List + + //查询当天插入的所有数据 + @Query("SELECT * FROM ${TaskSiteDataBean.tableName} WHERE task_id = :taskId order by seq") + fun queryRunningTask(taskId: Long): List? + + @Query("UPDATE ${TaskSiteDataBean.tableName} SET leaving = :leave WHERE task_id = :taskId and site_id = :siteId") + fun updateLeave(taskId: Long, siteId: Long, leave: Int) + + @Query("UPDATE ${TaskSiteDataBean.tableName} SET leaving = :leave , driving_status = :drivingStatusCurrent WHERE task_id = :taskId and site_id = :siteId") + fun updateDrivingStatusANdLeave(taskId: Long, siteId: Long, drivingStatusCurrent: Int, leave: Int) + + @Query("UPDATE ${TaskSiteDataBean.tableName} SET driving_status = :drivingStatusCurrent WHERE task_id = :taskId and site_id = :siteId") + fun updateDrivingStatus(taskId: Long, siteId: Long, drivingStatusCurrent: Int) + + // 删除过时数据 + @Query("DELETE FROM ${TaskSiteDataBean.tableName} WHERE event_save_time < :zeroTime") + fun deleteObsoleteData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int + + // 根据taskId删除所属站点信息 + @Query("DELETE FROM ${TaskSiteDataBean.tableName} WHERE task_id = :taskId") + fun deleteErrorDataByTaskId(taskId: Long) + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/WriteOffDataDao.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/WriteOffDataDao.kt new file mode 100644 index 0000000000..c727934ea2 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/dao/WriteOffDataDao.kt @@ -0,0 +1,46 @@ +package com.mogo.och.unmanned.repository.db.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.unmanned.repository.db.bean.WriteOffDataBean + +@Dao +interface WriteOffDataDao { + + //插入数据 + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg eventDataBean: WriteOffDataBean) + + //删除数据 + @Delete + fun delete(vararg eventDataBean: WriteOffDataBean) + + // 删除过时数据 + @Query("DELETE FROM ${WriteOffDataBean.tableName} WHERE event_save_time < :zeroTime") + fun deleteObsoleteData(zeroTime: Long = DateTimeUtil.getCurrentDateZero()): Int + + + @Query("SELECT * FROM ${WriteOffDataBean.tableName} WHERE event_save_time > :zeroTime and order_no = :orderNo order by event_save_time") + fun queryWriteOffByOrderNo(zeroTime: Long = DateTimeUtil.getCurrentDateZero(), orderNo: String): List? + + @Query("SELECT * FROM ${WriteOffDataBean.tableName} WHERE event_save_time > :zeroTime and task_id = :taskId and update_status = ${WriteOffDataBean.notUpdate}") + fun queryWaitWriteOffByTaskId(taskId: Long, zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List? + + @Query("SELECT * FROM ${WriteOffDataBean.tableName} WHERE update_status = ${WriteOffDataBean.notUpdate}") + fun queryWriteOffEventByStatusWithPage(): List? + + @Query("SELECT * FROM ${WriteOffDataBean.tableName} WHERE event_save_time > :zeroTime and task_id = :taskId and site_id = :siteId") + fun queryWriteOffByTaskAndSiteId(taskId: Long, siteId: Long, zeroTime: Long = DateTimeUtil.getCurrentDateZero()): List? + + @Query("SELECT count(1) FROM ${WriteOffDataBean.tableName} WHERE update_status = ${WriteOffDataBean.notUpdate}") + fun queryWriteOffByStatusWithPageCount(): Int + + @Query("UPDATE ${WriteOffDataBean.tableName} SET update_status = :updated ,update_time = :currentTimeMillis WHERE id = :id") + fun updateStatusAndTime(updated: Int, currentTimeMillis: Long, id: Int) + + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/ContraiDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/ContraiDb.kt new file mode 100644 index 0000000000..6fc4506a0c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/ContraiDb.kt @@ -0,0 +1,91 @@ +package com.mogo.och.unmanned.repository.db.repository + +import com.mogo.eagle.core.network.utils.digest.DigestUtils +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.unmanned.model.SynchDataModel +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.ContrailDataBean +import com.mogo.och.unmanned.repository.db.dao.ContrailDataDao + +object ContraiDb : IDbRepository { + + private var contrailDao: ContrailDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.contrailDataDao + register() + } + return field + } + + override fun release() { + contrailDao = null + } + + fun addOrUpdate(contrailDatalist: List) { + val runnable = Runnable { + // 校验数据个数 + contrailDao?.let { contrailDao -> + val needUpdatePoint = mutableListOf() + 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 + needUpdatePoint.add(it.lineId!!) + if (needUpdate != null) {// 更新 + it.id = needUpdate.id + contrailDao.update(it.csvFileUrl ?: "", it.csvFileMd5 + ?: "", it.txtFileUrl ?: "", it.txtFileMd5 + ?: "", System.currentTimeMillis(), md5Hex, needUpdate.id) + } else {// 插入新的 + contrailDao.insert(it) + } + } + } + if (needUpdatePoint.isNotEmpty()) { + SynchDataModel.synContraiInfo(needUpdatePoint) + } + } + } + BizLoopManager.runInIoThread(runnable) + } + + + fun deleteByLineId(lineId: Long) { + contrailDao?.deleteByLineId(lineId) + } + + fun queryAutopilotInfoByLineid(lineId: Long): ContrailDataBean? { + return contrailDao?.queryContrailByLineIdOne(lineId) + } + + fun saveRunningInfo( + lineId: Int, + csvFileMd5: String?, + csvFileUrl: String?, + txtFileUrl: String?, + txtFileMd5: String?, + contrailSaveTime: Long + ) { + val runningLine = ContrailDataBean( + lineId = lineId.toLong(), + csvFileUrl = csvFileUrl, + csvFileMd5 = csvFileMd5, + txtFileUrl = txtFileUrl, + txtFileMd5 = txtFileMd5, + contrailSaveTime = contrailSaveTime + ) + addOrUpdate(mutableListOf(runningLine)) + } + + fun upDateIdAndsource(contrailId: Long?, source: Int?, lineId: Long?) { + if (contrailId != null && source != null && lineId != null) { + contrailDao?.updateIdAndSource(contrailId, source, lineId) + } + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/EventDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/EventDb.kt new file mode 100644 index 0000000000..d6a906332e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/EventDb.kt @@ -0,0 +1,175 @@ +package com.mogo.och.unmanned.repository.db.repository + +import androidx.room.Transaction +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.common.module.manager.cache.OchSPManager +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.unmanned.model.EventModel +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.EventDataBean +import com.mogo.och.unmanned.repository.db.dao.EventDataDao +import io.reactivex.Observable + + +object EventDb : IDbRepository { + + private var eventDataDao: EventDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.eventDataDao + register() + } + return field + } + + + override fun release() { + eventDataDao = null + } + + fun saveEventTaskStart(shiftsId: Long, taskId: Long, lineId: Long, taskStartTime: Long, name: String, taskDate: Long) { + val event = EventDataBean() + event.eventType = EventDataBean.TaskStart + event.lineId = lineId + event.taskId = taskId + event.shiftsId = shiftsId + event.taskDate = taskDate + event.lineName = name + event.taskStartTime = taskStartTime + event.businessTime = DateTimeUtil.getCurrentTimeStamp() + event.writeVersion = DateTimeUtil.getCurrentTimeStamp() + event.driverId = LoginStatusManager.getOchLoginInfo()?.driverId ?: -1 + event.siteId = 0L + event.seq = 0 + event.msgId = "${OchSPManager.getSn()}_${DateTimeUtil.getCurrentTimeStamp()}" + BizLoopManager.runInIoThread { + eventDataDao?.insert(event) + EventModel.notifySyn() + } + } + + fun saveEventTaskArriveSite( + shiftsId: Long, + taskId: Long, + lineId: Long, + siteId: Long, + seq: Int, + taskStartTime: Long?, + lineName: String, + taskDate: Long? + ) { + val event = EventDataBean() + event.eventType = EventDataBean.TaskArriveSite + event.lineId = lineId + event.shiftsId = shiftsId + event.taskStartTime = taskStartTime + event.lineName = lineName + event.taskId = taskId + event.taskDate = taskDate + event.businessTime = DateTimeUtil.getCurrentTimeStamp() + event.writeVersion = DateTimeUtil.getCurrentTimeStamp() + event.siteId = siteId + event.driverId = LoginStatusManager.getOchLoginInfo()?.driverId ?: -1 + event.seq = seq + event.msgId = "${OchSPManager.getSn()}_${DateTimeUtil.getCurrentTimeStamp()}" + BizLoopManager.runInIoThread { + eventDataDao?.insert(event) + EventModel.notifySyn() + } + } + + fun saveEventTaskLeaveSite( + shiftsId: Long, + taskId: Long, + lineId: Long, + siteId: Long, + seq: Int, + taskStartTime: Long?, + lineName: String, + taskDate: Long + ) { + val event = EventDataBean() + event.eventType = EventDataBean.TaskLeaveSite + event.lineId = lineId + event.shiftsId = shiftsId + event.taskId = taskId + event.taskDate = taskDate + event.taskStartTime = taskStartTime + event.lineName = lineName + event.businessTime = DateTimeUtil.getCurrentTimeStamp() + event.writeVersion = DateTimeUtil.getCurrentTimeStamp() + event.driverId = LoginStatusManager.getOchLoginInfo()?.driverId ?: -1L + event.siteId = siteId + event.seq = seq + event.msgId = "${OchSPManager.getSn()}_${DateTimeUtil.getCurrentTimeStamp()}" + BizLoopManager.runInIoThread { + eventDataDao?.insert(event) + EventModel.notifySyn() + } + } + + fun saveEventTaskEnd( + shiftsId: Long, + taskId: Long, + lineId: Long, + taskStartTime: Long?, + lineName: String, + taskDate: Long + ) { + val event = EventDataBean() + event.eventType = EventDataBean.TaskEnd + event.lineId = lineId + event.shiftsId = shiftsId + event.taskId = taskId + event.taskDate = taskDate + event.lineName = lineName + event.taskStartTime = taskStartTime + event.businessTime = DateTimeUtil.getCurrentTimeStamp() + event.writeVersion = DateTimeUtil.getCurrentTimeStamp() + event.driverId = LoginStatusManager.getOchLoginInfo()?.driverId ?: -1L + event.siteId = 0L + event.seq = 0 + event.msgId = "${OchSPManager.getSn()}_${DateTimeUtil.getCurrentTimeStamp()}" + BizLoopManager.runInIoThread { + eventDataDao?.insert(event) + EventModel.notifySyn() + } + } + + fun queryWaitUpdateEvent(): List? { + return eventDataDao?.queryEventByStatusWithPage() + } + + fun queryWaitUpdateEventCount(): Int? { + return eventDataDao?.queryEventByStatusWithPageCount() + } + + fun queryLastData(): EventDataBean? { + val queryLastDataByWaritData = eventDataDao?.queryLastDataByWaritData() + if (queryLastDataByWaritData.isNullOrEmpty()) { + return null + } + return queryLastDataByWaritData.first() + } + + @Transaction + fun saveUpdateSuccess(waitUpdateEvent: List) { + waitUpdateEvent.forEach { + eventDataDao?.updateUpdateSatus(it.id, it.updateStatus, System.currentTimeMillis()) + } + } + + fun deleteObsoleteData() { + eventDataDao?.deleteObsoleteData()?.let { + OchChainLogManager.writeChainLogDb("删除临时数据", "Event删除数量:${it}") + } + } + + fun queryWaitUploadData(): Observable?>? { + return eventDataDao?.queryWaitUploadInfo() + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/LineDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/LineDb.kt new file mode 100644 index 0000000000..3f33a3c593 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/LineDb.kt @@ -0,0 +1,141 @@ +package com.mogo.och.unmanned.repository.db.repository + +import androidx.room.Transaction +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.dao.LineDataDao +import io.reactivex.Observable + +object LineDb : IDbRepository { + + private var lineDao: LineDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.lineDataDao + register() + } + return field + } + + + override fun release() { + lineDao = null + } + + + fun cleanWeltData() { + lineDao?.deleteWeltData() + } + + fun queryCanUserLine(): List? { + return lineDao?.loadData() + } + + /** + * 读取可用线路 + */ + fun queryCanUseLineRx(): Observable?>? { + return lineDao?.loadDataRx() + } + + fun checkAndUpdate(serverDatalist: List) { + val runable = object : Runnable { + @Transaction + override fun run() { + // 校验数据个数 + 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 -> + // 删除线路对应的站点 + SiteDb.deleteByLineId(lineId) + val runingTask = TaskDb.queryRunningTaskByLineId(lineId) + if (runingTask.isNullOrEmpty()) { + // 删除线路对应的自驾信息 + ContraiDb.deleteByLineId(lineId) + TaskDb.deleteByLineId(lineId) + } + } + } + } + + // 交集 服务器端 + val needUpdateByMd5 = serverDatalist - needAddDatas + // 交集 本地数据库 + val oldDataList = loadData - needMinusDatas + + val needDelete = mutableListOf() + val needUpDate = mutableListOf() + + needUpdateByMd5.forEach { + val oldList = oldDataList.filter { local -> local.lineId == it.lineId } + if (oldList.isNotEmpty()) { + oldList.forEachIndexed { index, lineBean -> + if (index == 0) { + if (lineBean.lineName == it.lineName && lineBean.endStationName == it.endStationName) { + // 数据没有变化 + } else { + it.id = lineBean.id + needUpDate.add(it) + } + } else { + // 站点多了 需要删除 + needDelete.add(lineBean) + } + } + } + } + lineDao.delete(*needDelete.toTypedArray()) + + needUpDate.forEach { updateItem -> + // 跟新数据 + lineDao.updateInfo(updateItem.lineName, updateItem.endStationName, updateItem.id) + } + } + } + } + + BizLoopManager.runInIoThread(runable) + } + + fun deleteObsoleteData() { + lineDao?.deleteObsoleteData()?.let { + OchChainLogManager.writeChainLogDb("删除临时数据", "Line删除数量:${it}") + } + } + + /** + * 没有线路就插入线路 + */ + fun saveRunningInfo(lineId: Int, lineName: String?, endStationName: String?) { + val queryByLineId = lineDao?.queryByLineId(lineId) + if (queryByLineId.isNullOrEmpty()) { + lineDao?.insert(LineDataBean(lineId = lineId.toLong(), lineName = lineName, endStationName = endStationName)) + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/PointDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/PointDb.kt new file mode 100644 index 0000000000..38dc4417b6 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/PointDb.kt @@ -0,0 +1,118 @@ +package com.mogo.och.unmanned.repository.db.repository + +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.ContrailDataBean +import com.mogo.och.unmanned.repository.db.bean.PointDataBean +import com.mogo.och.unmanned.repository.db.dao.PointDataDao + +object PointDb : IDbRepository { + + private var pointDao: PointDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.pointDataDao + register() + } + return field + } + + + override fun release() { + pointDao = null + } + + fun queryPointByLineId(lineId: Long?): List? { + lineId?.let { + return pointDao?.queryPointByLineId(lineId) + } + return null + } + + fun deletePointByLineIds(lineIds: List) { + pointDao?.deleteByLineId(lineIds) + } + + fun addOrUpdate(serverDataList: List) { + val contaiBeans = mutableListOf() + val needDelete = mutableListOf() + val needUpdateLineInfos = mutableListOf() + + serverDataList.forEach { contrailInfo -> + val lineId = contrailInfo.lineId + // 当前线路已排序的所有站点 + val siteList = SiteDb.querySiteByLineId(lineId) + val contraiBean = ContraiDb.queryAutopilotInfoByLineid(lineId) + + contraiBean?.let { + contraiBean.source = contrailInfo.source + contraiBean.contrailId = contrailInfo.contrailId + needUpdateLineInfos.add(contraiBean) + } + + val segmentPointList = contrailInfo.segmentPointList + needDelete.add(lineId) + segmentPointList.forEachIndexed { index, segmentPoint -> + val siteIndex = segmentPoint.segment + siteList?.let { siteListTemp -> + siteIndex?.let { siteIndexTemp -> + // 途径点和禁行点所有站点 + // TODO:("站点接口和轨迹接口绑定有问题的情况未来要处理") + if (siteIndexTemp < 0 || siteIndexTemp >= siteListTemp.size) return@forEachIndexed + val siteDataBean = siteListTemp[siteIndexTemp] + segmentPoint.pointList?.forEachIndexed { index, point -> + val pointTemp = PointDataBean() + pointTemp.lineId = lineId + pointTemp.contrailId = contrailInfo.contrailId + pointTemp.siteId = siteDataBean.siteId + pointTemp.md5 = contraiBean?.md5 ?: "" + pointTemp.seq = siteIndex + pointTemp.pointType = PointDataBean.pointTypePass + pointTemp.longitude = point.longitude + pointTemp.latitude = point.latitude + pointTemp.subSeq = index + contaiBeans.add(pointTemp) + } + segmentPoint.blackList?.forEachIndexed { index, black -> + val pointTemp = PointDataBean() + pointTemp.lineId = lineId + pointTemp.contrailId = contrailInfo.contrailId + pointTemp.siteId = siteDataBean.siteId + pointTemp.md5 = contraiBean?.md5 ?: "" + pointTemp.seq = siteIndex + pointTemp.pointType = PointDataBean.pointTypeBlack + pointTemp.longitude = black.longitude + pointTemp.latitude = black.latitude + pointTemp.subSeq = index + contaiBeans.add(pointTemp) + } + } + } + } + if (needUpdateLineInfos.size < 100) { + needUpdateLineInfos.forEach { + ContraiDb.upDateIdAndsource(it.contrailId, it.source, it.lineId) + } + } else { + MyDataBase.instance?.runInTransaction { + needUpdateLineInfos.forEach { + ContraiDb.upDateIdAndsource(it.contrailId, it.source, it.lineId) + } + } + } + if (needDelete.size < 100) { + pointDao?.deleteByLineId(needDelete) + } else { + pointDao?.deleteByLineIdTra(needDelete) + } + if (contaiBeans.size < 100) { + pointDao?.insert(*contaiBeans.toTypedArray()) + } else { + pointDao?.insertTra(*contaiBeans.toTypedArray()) + } + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/SiteDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/SiteDb.kt new file mode 100644 index 0000000000..e666ec2f18 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/SiteDb.kt @@ -0,0 +1,146 @@ +package com.mogo.och.unmanned.repository.db.repository + +import androidx.room.Transaction +import com.mogo.eagle.core.network.utils.digest.DigestUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.unmanned.model.SynchDataModel +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.SiteDataBean +import com.mogo.och.unmanned.repository.db.dao.SiteDataDao + +object SiteDb : IDbRepository { + + private const val TAG = "SiteDb" + + private var siteDataDao: SiteDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.siteDataDao + register() + } + return field + } + + override fun release() { + siteDataDao = null + } + + fun addOrUpdate(serverDataList: List) { + val runnable = object : Runnable { + @Transaction + override fun run() { + siteDataDao?.let { siteDataDao -> + val localAllSites = siteDataDao.queryAllSites() + if (localAllSites.isNullOrEmpty()) { + // 插入新数据 + siteDataDao.insert(*serverDataList.toTypedArray()) + return + } + val delPointByLineIds = mutableSetOf() + // 后台新增数据 + val needAddDatas = serverDataList - localAllSites + // 后台没有本地数据库有的未分配线路 + val needMinusDatas = localAllSites - serverDataList + + if (needAddDatas.isNotEmpty()) { + // 新增线路 + needAddDatas.forEach { + val md5Source = it.toString() + val md5Hex = DigestUtils.md5Hex(md5Source) + it.md5 = md5Hex + it.lineId?.let { lineId -> delPointByLineIds.add(lineId) } + } + // 新增插入新数据 + siteDataDao.insert(*needAddDatas.toTypedArray()) + } + + if (needMinusDatas.isNotEmpty()) { + // 删除线路 + siteDataDao.deleteById(*needMinusDatas.toTypedArray()) + needMinusDatas.forEach { + it.lineId?.let { it1 -> delPointByLineIds.add(it1) } + } + } + + // 交集 服务器端 + val needUpdateByMd5 = serverDataList - needAddDatas + // 交集 本地数据库 + val oldDataList = localAllSites - needMinusDatas + + val needDelete = mutableListOf() + val needUpDate = mutableListOf() + + + needUpdateByMd5.forEach { + val md5Source = it.toString() + val md5Hex = DigestUtils.md5Hex(md5Source) + val oldList = + oldDataList.filter { local -> local.siteId == it.siteId && local.lineId == it.lineId } + if (oldList.isNotEmpty()) { + oldList.forEachIndexed { index, siteDataBean -> + if (index == 0) { + if (siteDataBean.md5 == md5Hex) { + // 数据没有变化 + } else { + it.id = siteDataBean.id + it.md5 = md5Hex + needUpDate.add(it) + + } + } else { + needDelete.add(siteDataBean) + siteDataBean.lineId?.let { it1 -> delPointByLineIds.add(it1) } + } + } + } + } + needUpDate.forEach { updateDateItem -> + siteDataDao.updateInfo(updateDateItem.siteId, updateDateItem.lineId, updateDateItem.name, updateDateItem.nameKr, + updateDateItem.seq, updateDateItem.gcjLon, updateDateItem.gcjLat, updateDateItem.lon, updateDateItem.lat, + updateDateItem.introduction, updateDateItem.isPlayTts, updateDateItem.md5, updateDateItem.videoListDB, updateDateItem.tag, updateDateItem.id) + updateDateItem.lineId?.let { delPointByLineIds.add(it) } + } + siteDataDao.deleteById(*needDelete.toTypedArray()) + // 清除所有变更的站点 + if (delPointByLineIds.isNotEmpty()) { + val delPointList = delPointByLineIds.toMutableList() + PointDb.deletePointByLineIds(delPointList) + SynchDataModel.synContraiInfo(delPointList) + } + checkData() + } + } + + } + BizLoopManager.runInIoThread(runnable) + } + + fun checkData() { + CallerLogger.d(TAG, "检测站点数据") + siteDataDao?.checkData()?.let { list -> + list.forEach { + siteDataDao?.deleteById(it) + } + if (list.isNotEmpty()) { + OchChainLogManager.writeChainLogDb("数据检测", "有重复数据${list}") + checkData() + } + } + } + + fun deleteByLineId(lineId: Long) { + siteDataDao?.deleteByLineId(lineId) + } + + fun querySiteByLineId(lineId: Long): List? { + siteDataDao?.let { siteDataDao -> + return siteDataDao.querySitesByLineId(lineId) + } + return null + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/TaskDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/TaskDb.kt new file mode 100644 index 0000000000..d74942dd45 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/TaskDb.kt @@ -0,0 +1,228 @@ +package com.mogo.och.unmanned.repository.db.repository + +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.data.db.exception.DbException +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.db.dao.TaskDataDao +import com.mogo.och.unmanned.repository.exception.DataException +import io.reactivex.Observable + +object TaskDb : IDbRepository { + + private const val TAG = "${M_BUS}TaskDb" + + private var taskDataDao: TaskDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.taskDataDao + register() + } + return field + } + + override fun release() { + taskDataDao = null + } + + fun addOrUpdate(vararg lineDataBean: TaskDataBean) { + // 从接口恢复数据 + taskDataDao?.insert(*lineDataBean) + } + + fun addOrUpdate(serverDateList: List, lineId: Long?) { + val runable = object : Runnable { + override fun run() { + 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()) { + val needSaveTask = mutableListOf() + // 删除任务 + needMinusDatas.forEach { + if (it.status == TaskDataBean.useing || it.status == TaskDataBean.used) { + needSaveTask.add(it) + } + } + val failneedMinusDatas = needMinusDatas - needSaveTask + taskDataDao.delete(*failneedMinusDatas.toTypedArray()) + } + } + } + } + BizLoopManager.runInIoThread(runable) + + } + + /** + * 获取线路可用的任务 + */ + fun queryCanUserTask(lineId: Long): Observable?>? { + taskDataDao?.let { taskDataDao -> + // 查询当天未使用的任务 + return taskDataDao.queryUnuseTask(lineId).map { + it.filter { (System.currentTimeMillis() - it.taskStartTime!!) < 10 * 60 * 1000 } + } + } + return null + } + + fun startTask(shiftsId: Long, taskId: Long, lineId: Long, lineName: String): Observable? { + return Observable.just(taskId) + .flatMap { + var updateCount: Int? = 0 + var startTime = System.currentTimeMillis() + try { + // 更新task状态 + taskDataDao?.queryTaskByTaskIdOne(taskId)?.let { + it.startTime = System.currentTimeMillis() + it.status = TaskDataBean.useing + // 更新任务状态 + taskDataDao?.updateStatus(System.currentTimeMillis(), TaskDataBean.useing, it.id) + OchChainLogManager.writeChainLogDb("开始任务", "变更线路:${lineId}_${lineName}_task:${taskId} 为正在使用的状态") + } + CallerLogger.d(TAG, "更新任务状态用时:${System.currentTimeMillis() - startTime}") + startTime = System.currentTimeMillis() + updateCount = TaskSiteDb.startTask(shiftsId, taskId, lineId, lineName) + OchChainLogManager.writeChainLogDb("开始任务", "把正在使用的数据更新到RunningTask表格一共${updateCount}行数据") + CallerLogger.d(TAG, "插入正在运行的线路用时:${System.currentTimeMillis() - startTime}") + } catch (e: Exception) { + if (e is DbException) { + if (e.code == DbException.NEEDSYNDATA) { + // 重新同步 信息 + LineModel.refreshTask() + println("数据不全") + // 恢复数据 + taskDataDao?.queryTaskByTaskIdOne(taskId)?.let { + it.startTime = null + it.status = TaskDataBean.unUse + // 更新任务状态 + taskDataDao?.updateStatus( + System.currentTimeMillis(), + TaskDataBean.unUse, + it.id + ) + OchChainLogManager.writeChainLogDb( + "开始任务", + "异常情况${lineId}_${lineName}_task:${taskId} 为未使用的状态 原因:${e.message}" + ) + } + } + } + return@flatMap Observable.error(DataException(DataException.startTaskErrorCode, e.message + ?: "")) + } + updateCount?.let { + if (it <= 0) { + // 插入失败 + return@flatMap Observable.error(DataException(DataException.startTaskErrorCode, StringUtils.getString(R.string.module_och_no_data_inserted))) + } else { + // 开始任务成功 + return@flatMap Observable.just(true) + } + } + } + + } + + fun queryRunningTaskByLineId(lineId: Long): List? { + return taskDataDao?.queryRunningTaskByLineId(lineId) + } + + fun deleteByLineId(lineId: Long) { + taskDataDao?.deleteByLineId(lineId) + } + + fun queryRunningTask(): List? { + return taskDataDao?.queryRunningTaskByStatus() + } + + fun queryTaskById(taskId: Long): TaskDataBean? { + return taskDataDao?.queryTaskByTaskIdOne(taskId) + } + + fun queryAllTask(): List? { + return taskDataDao?.queryAllTask() + } + + + fun endTask(taskId: Long) { + BizLoopManager.runInIoThread { + taskDataDao?.endTask(taskId) + } + } + + fun deleteObsoleteData() { + taskDataDao?.deleteObsoleteData()?.let { + OchChainLogManager.writeChainLogDb("删除临时数据", "Task删除数量:${it}") + } + } + + fun saveRunningInfo(lineId: Int, taskId: Int, taskTime: Long) { + val runningTask = taskDataDao?.queryTaskByTaskIdOne(taskId.toLong()) + if (runningTask == null) { + val taskDataBean = TaskDataBean() + taskDataBean.taskId = taskId.toLong() + taskDataBean.lineId = lineId.toLong() + taskDataBean.taskStartTime = taskTime + taskDataBean.taskDate = DateTimeUtil.getCurrentDateZero() + taskDataBean.status = TaskDataBean.useing + taskDataDao?.insert(taskDataBean) + } else { + runningTask.status = TaskDataBean.useing + taskDataDao?.insert(runningTask) + } + } + + fun endTaskByOther(taskId: Long) { + BizLoopManager.runInIoThread { + val taskInfo = taskDataDao?.queryTaskByTaskIdOne(taskId) + if (taskInfo != null) { + if (taskInfo.status == TaskDataBean.unUse) { + taskDataDao?.endTask(taskId) + } + } + } + } + + fun restoreTask(taskId: Long) { + // 更新task状态 + taskDataDao?.queryTaskByTaskIdOne(taskId)?.let { + it.startTime = System.currentTimeMillis() + it.status = TaskDataBean.useing + // 更新任务状态 + taskDataDao?.updateStatus(System.currentTimeMillis(), TaskDataBean.useing, it.id) + OchChainLogManager.writeChainLogDb("恢复任务", "线路任务改为正在执行的状态") + } + } + + fun resetShiftsIdDetail() { + taskDataDao?.setShiftsIdDetail() + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/TaskSiteDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/TaskSiteDb.kt new file mode 100644 index 0000000000..e4c34b2a15 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/TaskSiteDb.kt @@ -0,0 +1,173 @@ +package com.mogo.och.unmanned.repository.db.repository + +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.data.db.exception.DbException +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean +import com.mogo.och.unmanned.repository.db.dao.TaskSiteDataDao + +object TaskSiteDb : IDbRepository { + + private const val TAG = "${M_BUS}TaskSiteDb" + + private var taskSiteDataDao: TaskSiteDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.taskSiteDataDao + register() + } + return field + } + + override fun release() { + taskSiteDataDao = null + } + + + fun addOrUpdate(vararg lineDataBean: TaskSiteDataBean) { + taskSiteDataDao?.insert(*lineDataBean) + } + + // 开始线路 + fun startTask(shiftsId: Long, taskId: Long, linId: Long, lineName: String): Int? { + // 获取线路的站点 + val querySites = SiteDb.querySiteByLineId(linId)?.distinctBy { it.siteId }?.sortedBy { it.seq } + if (querySites.isNullOrEmpty()) { +// throw DbException(DbException.NEEDSYNDATA,"没有站点数据") + throw DbException(DbException.NEEDSYNDATA, StringUtils.getString(R.string.module_och_no_station_data)) + } + querySites.forEachIndexed { index, siteDataBean -> + if (index + 1 != siteDataBean.seq) { +// throw DbException(DbException.NEEDSYNDATA,"站点数据排序不对") + throw DbException(DbException.NEEDSYNDATA, StringUtils.getString(R.string.module_och_station_data_order_incorrect)) + } + } + val toTaskSiteDatas = TaskSiteDataBean.toTaskSiteDatas( + querySites, + shiftsId, + taskId, + lineName + ) + if (toTaskSiteDatas.size < 2) { +// throw DbException(DbException.NEEDSYNDATA,"站点数据不全请稍后再试") + throw DbException(DbException.NEEDSYNDATA, StringUtils.getString(R.string.module_och_station_data_incomplete)) + } + // 把线路所有的站点搬迁到运行中表格中 + val result = taskSiteDataDao?.insert(*toTaskSiteDatas.toTypedArray()) + return if (result.isNullOrEmpty()) { + null + } else { + result.size + } + } + + // 滑动出发 + fun updateLeave(taskId: Long, siteId: Long, leave: Boolean) { + BizLoopManager.runInIoThread { + taskSiteDataDao?.updateLeave(taskId, siteId, if (leave) 1 else 0) + } + } + + fun updateDrivingStatus(taskId: Long, siteId: Long, drivingStatus: Int) { + BizLoopManager.runInIoThread { + taskSiteDataDao?.updateDrivingStatus(taskId, siteId, drivingStatus) + } + } + + fun updateDrivingStatusAndLeave( + taskId: Long, + siteId: Long, + drivingStatus: Int, + leave: Boolean + ) { + BizLoopManager.runInIoThread { + taskSiteDataDao?.updateDrivingStatusANdLeave( + taskId, + siteId, + drivingStatus, + if (leave) 1 else 0 + ) + } + } + + fun queryRunningTask(taskId: Long): List? { + return taskSiteDataDao?.queryRunningTask(taskId) + } + + fun deleteErrorData(taskId: Long) { + taskSiteDataDao?.deleteErrorDataByTaskId(taskId) + } + + fun deleteObsoleteData() { + taskSiteDataDao?.deleteObsoleteData()?.let { + OchChainLogManager.writeChainLogDb("删除临时数据", "rurnning Task删除数量:${it}") + } + } + + /** + * 从后台恢复正在执行的任务 + */ + fun restoreRunningTask( + shiftsId: Long, + taskId: Long, + currentSiteId: Long, + leaving: Boolean, + lineInfo: LineDataBean + ) { + val taskHistory = queryRunningTask(taskId) + if (!taskHistory.isNullOrEmpty()) { + //有错误数据 + deleteErrorData(taskId) + } + // 获取线路的站点 + val querySites = SiteDb.querySiteByLineId(lineInfo.lineId!!)?.distinctBy { it.siteId } + if (querySites.isNullOrEmpty()) { +// throw DbException(DbException.NEEDSYNDATA,"没有站点数据") + throw DbException(DbException.NEEDSYNDATA, StringUtils.getString(R.string.module_och_no_station_data)) + } + val toTaskSiteDatas = TaskSiteDataBean.toTaskSiteDatas( + querySites, + shiftsId, + taskId, + lineInfo.lineName!! + ) + val resetData = resetInfo(currentSiteId, leaving, toTaskSiteDatas) + // 把线路所有的站点搬迁到运行中表格中 + taskSiteDataDao?.insert(*resetData.toTypedArray()) + } + + fun resetInfo( + currentSiteId: Long, + leaving: Boolean, + runningSite: MutableList + ): MutableList { + var currentSeq = 0 + runningSite.forEach { + if (it.siteId == currentSiteId) { + currentSeq = it.seq ?: 0 + it.drivingStatus = TaskSiteDataBean.drivingStatusCurrent + it.leaving = leaving + return@forEach + } + } + runningSite.forEach { + val seq = it.seq ?: 0 + if (seq < currentSeq) { + it.drivingStatus = TaskSiteDataBean.drivingStatusPassed + it.leaving = true + } else if (seq > currentSeq) { + it.drivingStatus = TaskSiteDataBean.drivingStatusNotArrived + it.leaving = false + } + } + return runningSite + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/WriteOffDb.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/WriteOffDb.kt new file mode 100644 index 0000000000..881b10f8a3 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/repository/WriteOffDb.kt @@ -0,0 +1,84 @@ +package com.mogo.och.unmanned.repository.db.repository + +import androidx.room.Transaction +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.unmanned.model.EventModel +import com.mogo.och.unmanned.repository.db.IDbRepository +import com.mogo.och.unmanned.repository.db.MyDataBase +import com.mogo.och.unmanned.repository.db.bean.WriteOffDataBean +import com.mogo.och.unmanned.repository.db.dao.WriteOffDataDao + +object WriteOffDb : IDbRepository { + + private var writeOffDataDao: WriteOffDataDao? = null + get() { + if (field == null) { + field = MyDataBase.instance?.writeOffDataDao + register() + } + return field + } + + override fun release() { + writeOffDataDao = null + } + + fun addOrUpdate(vararg lineDataBean: WriteOffDataBean) { + writeOffDataDao?.insert(*lineDataBean) + EventModel.notifySyn() + } + + + fun queryWaitUpdateEventCount(orderNo: String): List? { + val queryWriteOffByOrderNo = writeOffDataDao?.queryWriteOffByOrderNo(orderNo = orderNo) + return queryWriteOffByOrderNo + } + + fun queryWaitUpdateEvent(): List? { + return writeOffDataDao?.queryWriteOffEventByStatusWithPage() + } + + @Transaction + fun saveUpdateSuccess( + writeOffEvents: List, + updated: Int, + currentTimeMillis: Long + ) { + writeOffEvents.forEach { + writeOffDataDao?.updateStatusAndTime(updated, currentTimeMillis, it.id) + } + } + + fun queryWaitUpdateEventByTaskId(taskId: Long): List? { + return writeOffDataDao?.queryWaitWriteOffByTaskId(taskId) + } + + fun queryWaitUpdateEventCountByTaskId(taskId: Long): Int { + val queryWriteOffByOrderNo = writeOffDataDao?.queryWaitWriteOffByTaskId(taskId) + var count4Persion = 0 + queryWriteOffByOrderNo?.forEach { wirteoffItem -> + if (wirteoffItem.ticketSize == null || wirteoffItem.ticketSize!! < 1) { + wirteoffItem.ticketSize = 1 + } + count4Persion += (wirteoffItem.ticketSize ?: 1) + } + + return count4Persion + } + + fun queryWriteOffByTaskAndSiteId(taskId: Long, siteId: Long): List? { + return writeOffDataDao?.queryWriteOffByTaskAndSiteId(taskId, siteId) + } + + fun deleteObsoleteData() { + writeOffDataDao?.deleteObsoleteData()?.let { + OchChainLogManager.writeChainLogDb("删除临时数据", "WriteOff删除数量:${it}") + } + } + + fun queryWaitUpdateWriteOffCount(): Int? { + return writeOffDataDao?.queryWriteOffByStatusWithPageCount() + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/transform/DataBaseTransform.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/transform/DataBaseTransform.kt new file mode 100644 index 0000000000..da546508ce --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/db/transform/DataBaseTransform.kt @@ -0,0 +1,14 @@ +package com.mogo.och.unmanned.repository.db.transform + +import io.reactivex.Observable +import io.reactivex.ObservableSource +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.functions.Function +import io.reactivex.schedulers.Schedulers + +fun Observable.transform4DataBase(transfor: Function>): Observable { + return flatMap(transfor) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/exception/DataException.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/exception/DataException.kt new file mode 100644 index 0000000000..78dbab1901 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/exception/DataException.kt @@ -0,0 +1,16 @@ +package com.mogo.och.unmanned.repository.exception + +class DataException : RuntimeException { + var code: Int = 0 + var msg: String = "" + + constructor() : super() + constructor(code: Int, message: String) : super("${code}_${message}") { + this.code = code + this.msg = message + } + + companion object { + val startTaskErrorCode = 10010 + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/ILineRepository.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/ILineRepository.kt new file mode 100644 index 0000000000..70a2918926 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/ILineRepository.kt @@ -0,0 +1,50 @@ +package com.mogo.och.unmanned.repository.line + +import android.content.Context +import com.mogo.eagle.core.data.BaseData +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import io.reactivex.Observable + +interface ILineRepository { + + fun loadCurrentTaskInfo(): Observable? + + fun queryCanUseLine(): Observable?>? + + fun queryCanUserTask(lineId: Long): Observable?>? + + fun startTask(shiftsId: Long, taskId: Long, lineId: Long, taskTime: Long, lineName: String): Observable? + + fun leaveStation( + seq: Int, + siteId: Long, + shiftsId: Long, + taskId: Long, + lineId: Long, + taskStartTime: Long, + taskDate: Long + ): Observable? + + fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable? + + fun endTask(shiftsId: Long, taskId: Long): Observable? + + fun queryCarExecutableTaskList(ochCommonServiceCallback: OchCommonServiceCallback) + + fun reportCabinEvent(context: Context?, data: ShuttleEventRequest?, callback: OchCommonServiceCallback?) + + fun haveRunningTask(): Boolean { + return false + } + + fun release() + fun endTaskByOther(taskId: Long) {} + + fun queryPointsByLineIds(lines: MutableList): Observable>? + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/impl/NormalRepository.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/impl/NormalRepository.kt new file mode 100644 index 0000000000..cf6d6cadf9 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/impl/NormalRepository.kt @@ -0,0 +1,229 @@ +package com.mogo.och.unmanned.repository.line.impl + +import android.content.Context +import com.mogo.commons.env.Project +import com.mogo.commons.env.ProjectUtils +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.data.bean.BusStationBean +import com.mogo.och.data.bean.ContraiInfo +import com.mogo.och.data.bean.LineInfo +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean +import com.mogo.och.unmanned.repository.line.ILineRepository +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.exception.NetException +import com.mogo.och.unmanned.repository.net.project.dali.bus.DaliBusServiceManager +import com.mogo.och.unmanned.repository.net.project.mogo.bus.MogoBusServiceManager +import com.mogo.och.unmanned.repository.net.project.mogo.shuttle.MogoShuttleServiceManager +import io.reactivex.Observable + +class NormalRepository : ILineRepository { + + private val tag = "${M_BUS}NormalRepository" + + private var normalLineInterface: NetInterface? = null + get() { + if (field == null) { + when (ProjectUtils.getProjectType()) { + Project.SAAS -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { +// throw NetException("非缓存weakNetInterface 初始化环境错误 isBus") + throw NetException(StringUtils.getString(R.string.module_och_init_env_error_bus)) + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { +// throw NetException("非缓存weakNetInterface 初始化环境错误 isBus") + throw NetException(StringUtils.getString(R.string.module_och_init_env_error_bus)) + } + } + + Project.DALI -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { +// throw NetException("非缓存weakNetInterface 初始化环境错误 isBus") + throw NetException(StringUtils.getString(R.string.module_och_init_env_error_bus)) + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = DaliBusServiceManager + } + } + + Project.MOGO -> { + field = MogoBusServiceManager() + } + + else -> { + field = MogoShuttleServiceManager() + } + } + } + return field + } + + init { + + } + + override fun loadCurrentTaskInfo(): Observable? { + return normalLineInterface?.queryBusRoutes() + ?.flatMap { busRoutesResult -> + if (!busRoutesResult.sites.isNullOrEmpty() && busRoutesResult.sites.size > 1) { + OchChainLogManager.writeChainLogDb( + "业务数据", + "本地没有正在运行的数据,服务器端有${busRoutesResult}" + ) + CallerLogger.d(tag, "本地没有正在运行的数据,服务器端有${busRoutesResult}") + val result = mutableListOf() + var temp: BusStationBean? + var currentStationIndex = -1 + var lineInfo: LineInfo? = null + busRoutesResult.sites.forEachIndexed { index, taskAndsite -> + temp = BusStationBean() + temp?.drivingStatus = taskAndsite.drivingStatus + temp?.lat = taskAndsite.lat + temp?.lon = taskAndsite.lon + temp?.gcjLat = taskAndsite.gcjLat + temp?.gcjLon = taskAndsite.gcjLon + temp?.introduction = taskAndsite.introduction + temp?.isLeaving = taskAndsite.isLeaving + temp?.name = taskAndsite.name + temp?.nameKr = taskAndsite.nameKr + temp?.isPlayTts = java.lang.Boolean.TRUE == taskAndsite.isPlayTts + temp?.seq = taskAndsite.seq + temp?.siteId = taskAndsite.siteId + result.add(temp!!) + // 正在进行中的任务 + if (temp!!.drivingStatus == TaskSiteDataBean.drivingStatusCurrent) { + if (temp!!.tag != 2) { + currentStationIndex = index + } + } + // 线路信息 + if (lineInfo == null && busRoutesResult.name != null) { + lineInfo = LineInfo(busRoutesResult.lineId.toLong(), busRoutesResult.name, orderId = busRoutesResult.taskId.toString()) + } + + } + if (currentStationIndex == -1) { + val pos = result.indexOfFirst { it.tag != 2 } + currentStationIndex = if (pos != -1) { + pos + } else { + 0 + } + } + lineInfo?.multiMap?.put("taskInfo", LineModel.getTaskTime()) + lineInfo?.siteInfos = result + LineManager.setLineInfo(lineInfo) + + LineManager.setContraiInfo( + ContraiInfo(busRoutesResult.lineId.toLong(), busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5, + busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5, + busRoutesResult.contrailSaveTime) + ) + + + val tempTask = TaskDataBean() + tempTask.taskId = busRoutesResult.taskId.toLong() + tempTask.taskStartTime = busRoutesResult.taskTime + tempTask.lineId = busRoutesResult.lineId.toLong() + LineModel.currentTask = tempTask + + LineModel.stationList = result + LineModel.startStationIndex = currentStationIndex + LineModel.stationList?.let { stationlist -> + val startStation = stationlist[LineModel.startStationIndex] + if (LineModel.startStationIndex < stationlist.size - 1) { + //遍历当前路段起始点之后的数组,第一个正常停靠点即为该段终点 + val subStationList = stationlist.subList(LineModel.startStationIndex + 1, stationlist.size) + val endStation = subStationList.firstOrNull { bean -> + bean.tag != 2 + } +// val endStation = stationlist[LineModel.startStationIndex + 1] + LineModel.nextStationIndex = stationlist.indexOf(endStation) + LineManager.setStartAndEndStation(startStation, endStation) + LineModel.callEyeMap(7) + } + } + return@flatMap Observable.just(true) + } + return@flatMap Observable.just(false) + } + } + + override fun queryCanUseLine(): Observable?>? { + return normalLineInterface?.queryBusLines() + } + + override fun queryCanUserTask(lineId: Long): Observable?>? { + return normalLineInterface?.queryBusTaskByLineId(lineId) + } + + override fun startTask( + shiftsId: Long, + taskId: Long, + lineId: Long, + taskTime: Long, + lineName: String + ): Observable? { + return normalLineInterface?.switchLine(taskId) + } + + override fun leaveStation( + seq: Int, + siteId: Long, + shiftsId: Long, + taskId: Long, + lineId: Long, + taskStartTime: Long, + taskDate: Long + ): Observable? { + return normalLineInterface?.leaveStation(seq, siteId, taskId, System.currentTimeMillis()) + } + + override fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable? { + return normalLineInterface?.arriveSiteStation( + seq, + siteId, + taskId, + System.currentTimeMillis() + ) + } + + override fun endTask(shiftsId: Long, taskId: Long): Observable? { + return normalLineInterface?.endTask(taskId) + } + + override fun queryCarExecutableTaskList(ochCommonServiceCallback: OchCommonServiceCallback) { + + } + + override fun queryPointsByLineIds(lines: MutableList): Observable>? { + return Observable.just(ArrayList()) + } + + override fun reportCabinEvent( + context: Context?, + data: ShuttleEventRequest?, + callback: OchCommonServiceCallback? + ) { + + } + + override fun release() { + normalLineInterface = null + CallerLogger.d(tag, "重置 normalNetInterface") + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/impl/WeaknetRepository.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/impl/WeaknetRepository.kt new file mode 100644 index 0000000000..72d4f54e76 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/line/impl/WeaknetRepository.kt @@ -0,0 +1,530 @@ +package com.mogo.och.unmanned.repository.line.impl + +import android.content.Context +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.env.Project +import com.mogo.commons.env.ProjectUtils +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.data.bean.ContraiInfo +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.bean.request.QueryPointRequest +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.BusRoutesResponse +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.constant.BusConst +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.model.LineModel.currentTask +import com.mogo.och.unmanned.repository.db.bean.ContrailDataBean +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskSiteDataBean +import com.mogo.och.unmanned.repository.db.repository.ContraiDb +import com.mogo.och.unmanned.repository.db.repository.EventDb +import com.mogo.och.unmanned.repository.db.repository.LineDb +import com.mogo.och.unmanned.repository.db.repository.SiteDb +import com.mogo.och.unmanned.repository.db.repository.TaskDb +import com.mogo.och.unmanned.repository.db.repository.TaskSiteDb +import com.mogo.och.unmanned.repository.line.ILineRepository +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.exception.NetException +import com.mogo.och.unmanned.repository.net.project.dali.shuttle.DaliShuttleServiceManager +import com.mogo.och.unmanned.repository.net.project.saas.bus.SaasBusServiceManager +import com.mogo.och.unmanned.repository.net.project.saas.scheduled.SaasScheduledServiceManager +import com.mogo.och.unmanned.repository.net.project.saas.shuttle.SaasShuttleServiceManager +import io.reactivex.Observable + +class WeaknetRepository : ILineRepository { + private val TAG = "${M_BUS}ShuttleSaasRepository" + private val context = AbsMogoApplication.getApp() + + private var weakNetInterface: NetInterface? = null + get() { + if (field == null) { + when (ProjectUtils.getProjectType()) { + Project.SAAS -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = SaasShuttleServiceManager + } else if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + field = SaasScheduledServiceManager + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = SaasBusServiceManager + } + } + + Project.DALI -> { + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = DaliShuttleServiceManager + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { +// throw NetException("缓存weakNetInterface 初始化环境错误 isBus") + throw NetException(StringUtils.getString(R.string.module_och_cache_init_env_error_bus)) + } + } + + Project.MOGO -> { +// throw NetException("缓存weakNetInterface 初始化环境错误 MOGO") + throw NetException(StringUtils.getString(R.string.module_och_cache_init_env_error_mogo)) + } + + else -> { +// throw NetException("缓存weakNetInterface 初始化环境错误 未知") + throw NetException(StringUtils.getString(R.string.module_och_cache_init_env_error_unknown)) + } + } + } + return field + } + + override fun loadCurrentTaskInfo(): Observable? { + return Observable.just(123) + .flatMap { + // 获取正在运行的任务 + val runningTaskInfo = TaskDb.queryRunningTask() + if (runningTaskInfo.isNullOrEmpty()) { + // 本地没有进行中的任务 + CallerLogger.d(TAG, "loadCurrentTaskInfo 没有查询到正在运行的任务") + return@flatMap loadServerRuningTask(1) + } else if (runningTaskInfo.size > 1) { + // 本地有多条正在进行的任务 需要check event + // 1 比对event表 1 清理错误数据 2 加载后台数据 + CallerLogger.d(TAG, "loadCurrentTaskInfo 查询到多个正在执行的任务") + return@flatMap selectRightData(runningTaskInfo) + } else { + // 只有一条进行中的任务 + currentTask = runningTaskInfo.first() + // 恢复站点信息 + currentTask?.taskId?.let { + // 获取正在进行中的具体信息 + val runnintTaskAndSites = TaskSiteDb.queryRunningTask(it)?.distinctBy { it.siteId } + if (runnintTaskAndSites.isNullOrEmpty() || runnintTaskAndSites.size < 2) { + CallerLogger.d(TAG, "异常情况:有任务:${runningTaskInfo} runningTask 表格没有对应的数据:${runnintTaskAndSites}") + OchChainLogManager.writeChainLogDb("加载任务", "异常情况:有任务:${runningTaskInfo} runningTask 表格没有对应的数据:${runnintTaskAndSites}") + TaskSiteDb.deleteErrorData(it) + return@flatMap loadServerRuningTask(1) + } + val db2Beans = BusRoutesResponse.db2Beans(runnintTaskAndSites, currentTask!!.lineId) + LineModel.stationList = db2Beans.first + LineModel.startStationIndex = db2Beans.second + LineModel.stationList?.let { stationlist -> + val startStation = stationlist[LineModel.startStationIndex] + if (LineModel.startStationIndex < stationlist.size - 1) { + //遍历当前路段起始点之后的数组,第一个正常停靠点即为该段终点 + val subStationList = stationlist.subList(LineModel.startStationIndex + 1, stationlist.size) + val endStation = subStationList.firstOrNull { bean -> + bean.tag != 2 + } + LineModel.nextStationIndex = stationlist.indexOf(endStation) +// val endStation = stationlist[LineModel.startStationIndex + 1] + LineManager.setStartAndEndStation(startStation, endStation) + LineModel.callEyeMap(8) + } + } + + } + // 设置自动驾驶信息 + currentTask?.lineId?.let { + ContraiDb.queryAutopilotInfoByLineid(it)?.apply { + if (lineId == null || lineId!! < 0L || csvFileUrl.isNullOrEmpty() || csvFileMd5.isNullOrEmpty() || txtFileUrl.isNullOrEmpty() || txtFileMd5.isNullOrEmpty()) { +// ToastUtils.showLong("请设置轨迹信息") + ToastUtils.showLong(R.string.module_och_set_line_info) + OchChainLogManager.writeChainLogAutopilot("轨迹错误", this.toString()) + CallerLogger.d(TAG, "轨迹错误,$this") + } + LineManager.setContraiInfo(ContraiInfo(lineId!!, csvFileUrl!!, csvFileMd5!!, txtFileUrl!!, txtFileMd5!!, contrailSaveTime!!, source = source + ?: ContrailDataBean.SOURCETYPEROUTING)) + } + } + return@flatMap Observable.just(true) + } + } + + + } + + private fun selectRightData(runningTaskInfo: List): Observable? { + return Observable.just(123) + .flatMap { + // 查找最新已经上报的任务 + val sorted = runningTaskInfo.sortedBy { + it.startTime + } + val tempList = sorted.toMutableList() + val possible = tempList.removeFirst() + val queryLastData = EventDb.queryLastData() + if (queryLastData != null) { + if (possible.taskId == queryLastData.taskId) { + // 最后一个事件和最新的task一直 恢复数据 + tempList.forEach { + it.status = TaskDataBean.used + } + TaskDb.addOrUpdate(*tempList.toTypedArray()) + CallerLogger.d(TAG, "异常情况:多个正在进行的任务 task:${runningTaskInfo} event:${queryLastData.taskId}有一个和event表对应使用相同的一个 另一个置为已使用") + OchChainLogManager.writeChainLogDb("加载任务", "异常情况:多个正在进行的任务 task:${runningTaskInfo} event:${queryLastData.taskId}有一个和event表对应使用相同的一个 另一个置为已使用") + return@flatMap loadServerRuningTask(1) + } + } + // 全部置为已使用 通过接口恢复数据 + runningTaskInfo.forEach { + it.status = TaskDataBean.used + } + CallerLogger.d(TAG, "异常情况:多个正在进行的任务 task:${runningTaskInfo} 全部置为已使用 从后台加载正在使用的任务") + OchChainLogManager.writeChainLogDb("加载任务", "异常情况:多个正在进行的任务 task:${runningTaskInfo} 全部置为已使用 从后台加载正在使用的任务") + TaskDb.addOrUpdate(*runningTaskInfo.toTypedArray()) + return@flatMap loadCurrentTaskInfo() + } + + } + + private fun loadServerRuningTask(loadCount: Int): Observable? { + if (ProjectUtils.isSaas()) { + // 从登录接口获取数据 + // 1、从登录接口获取业务数据 + // 2、check 数据库数据 + // 3、数据库没有数据 做延迟等待同步接口同步基础数据 ?? 等待基础数据同步完在进行 + // 4、恢复本地正在运行的数据 + val loginInfo = LoginStatusManager.getOchBizInfo() + return Observable.just(loginInfo).flatMap { + // check数据 是否正在之心 + val taskId = if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) || + AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + it.taskId + } else { + it.shiftsId + } + val taskDate = it.taskDate + val currentSiteId = it.currentSite + val leaving = it.leaving + val lineId = it.lineId ?: 0L + + if (lineId <= 0) { + return@flatMap Observable.just(false) + } + if (taskId <= 0 || currentSiteId <= 0) { + return@flatMap Observable.just(false) + } + // 日期是否正确 + if (AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)) { + if (!DateTimeUtil.isSameDay(System.currentTimeMillis(), taskDate)) { + return@flatMap Observable.just(false) + } + } + + // region 任务本地是否存在 + val allTask = TaskDb.queryAllTask() + if (allTask.isNullOrEmpty()) { + if (loadCount == BusConst.waitCount) + return@flatMap Observable.just(false) + CallerLogger.d(TAG, "本地没有任务等待2s后 重新查询") + Thread.sleep(BusConst.waitSysAllData) + return@flatMap loadServerRuningTask(loadCount + 1) + } + // 服务端任务已被删除 + val queryTaskById = TaskDb.queryTaskById(taskId) + if (queryTaskById == null) { + CallerLogger.d(TAG, "服务端正在执行${taskId},本地没有此任务") + OchChainLogManager.writeChainLogDb("错误信息", "服务端正在执行${taskId},本地没有此任务") + return@flatMap Observable.just(false) + } else { + // 本地任务已经被执行 + if (queryTaskById.status == TaskDataBean.used) { + return@flatMap Observable.just(false) + } + } + // endregion + + // region 检查线路 + val allLineData = LineDb.queryCanUserLine() + if (allLineData.isNullOrEmpty()) { + if (loadCount == BusConst.waitCount) + return@flatMap Observable.just(false) + CallerLogger.d(TAG, "本地没有线路等待2s后 重新查询") + Thread.sleep(BusConst.waitSysAllData) + if (loadCount > 1) { + return@flatMap loadServerRuningTask(1) + } else { + return@flatMap loadServerRuningTask(loadCount + 1) + } + } + // 正在执行的站点是否在此线路中 + var containLine = false + var lineInfo: LineDataBean? = null + allLineData.forEach { lineItem -> + if (lineItem.lineId == lineId) { + containLine = true + lineInfo = lineItem + } + } + if (!containLine) { + CallerLogger.d(TAG, "服务端正在执行${lineId},线路已被删除") + OchChainLogManager.writeChainLogDb("错误信息", "服务端正在执行${lineId},线路已被删除") + return@flatMap Observable.just(false) + } + // endregion + + // region 检查站点 包括个数和是否包含 currentSite + val siteWithLine = SiteDb.querySiteByLineId(lineId) + if (siteWithLine.isNullOrEmpty() || siteWithLine.size < 2) { + CallerLogger.d(TAG, "服务端正在执行${taskId},线路站点错误${siteWithLine}") + OchChainLogManager.writeChainLogDb("错误信息", "服务端正在执行${taskId},线路站点错误${siteWithLine}") + return@flatMap Observable.just(false) + } + // 正在执行的站点是否在此线路中 + var containSite = false + siteWithLine.forEach { + if (it.siteId == currentSiteId) { + containSite = true + } + } + if (!containSite) { + CallerLogger.d(TAG, "服务端正在执行${taskId},线路站点错误${siteWithLine}") + OchChainLogManager.writeChainLogDb("错误信息", "服务端正在执行${taskId},${siteWithLine}站点不包含正在执行的站点:${currentSiteId}") + return@flatMap Observable.just(false) + } + // endregion + + // 恢复任务 + TaskDb.restoreTask(taskId) + + // 恢复正在执行任务表 + TaskSiteDb.restoreRunningTask(it.shiftsId, taskId, currentSiteId, leaving, lineInfo!!) + + return@flatMap loadCurrentTaskInfo() + } + } else { + // 从特定接口回复数据 + return weakNetInterface?.queryBusRoutes()?.flatMap { busRoutesResult -> + if (!busRoutesResult.sites.isNullOrEmpty() && busRoutesResult.sites.size > 1) { + val queryTaskById = TaskDb.queryTaskById(busRoutesResult.taskId.toLong()) + if (queryTaskById == null || queryTaskById.status != TaskDataBean.used) { + OchChainLogManager.writeChainLogDb( + "业务数据", + "本地没有正在运行的数据,服务器端有${busRoutesResult}" + ) + CallerLogger.d(TAG, "本地没有正在运行的数据,服务器端有${busRoutesResult}") + LineDb.saveRunningInfo( + busRoutesResult.lineId, + busRoutesResult.name, + busRoutesResult.sites.last().name + ) + TaskDb.saveRunningInfo( + busRoutesResult.lineId, + busRoutesResult.taskId, + busRoutesResult.taskTime + ) + ContraiDb.saveRunningInfo( + busRoutesResult.lineId, + busRoutesResult.csvFileMd5, + busRoutesResult.csvFileUrl, + busRoutesResult.txtFileUrl, + busRoutesResult.txtFileMd5, + busRoutesResult.contrailSaveTime + ) + BusRoutesResponse.bean2Db( + busRoutesResult.sites, + busRoutesResult.lineId.toLong(), + busRoutesResult.name, + busRoutesResult.taskId.toLong() + ) + return@flatMap loadCurrentTaskInfo() + } else { + return@flatMap Observable.just(false) + } + } + return@flatMap Observable.just(false) + } + } + } + + override fun queryCanUseLine(): Observable?>? { + return LineDb.queryCanUseLineRx() + } + + override fun queryCanUserTask(lineId: Long): Observable?>? { + return TaskDb.queryCanUserTask(lineId) + } + + override fun startTask( + shiftsId: Long, + taskId: Long, + lineId: Long, + taskTime: Long, + lineName: String + ): Observable? { + return TaskDb.startTask(shiftsId, taskId, lineId, lineName) + } + + /** + * 滑动出发 + */ + override fun leaveStation( + seq: Int, + siteId: Long, + shiftsId: Long, + taskId: Long, + lineId: Long, + taskStartTime: Long, + taskDate: Long + ): Observable? { + return Observable.just(taskId) + .flatMap { + //开始站点: leaving false->true + LineManager.getStartStation { + TaskSiteDb.updateLeave(taskId, it.siteId.toLong(), true) + OchChainLogManager.writeChainLogDb( + "滑动出发", + "task:${currentTask}__taskId:${currentTask?.taskId}" + ) + CallerLogger.d(TAG, "滑动出发:task:${currentTask}__taskId:${currentTask?.taskId}") + // 设置滑动出发任务 + LineManager.getLineInfo { lineInfo -> + EventDb.saveEventTaskLeaveSite( + shiftsId, + taskId, + lineId, + it.siteId.toLong(), + it.seq, + taskStartTime, + lineInfo.lineName, + taskDate + ) + } + + } + val (startStation, endStation) = LineManager.getStations() + val changeInfo = + "taskId:${currentTask?.taskId}--lineId:${currentTask?.lineId}--currentStationName:${startStation?.name}--finalNextStationName:${endStation?.name}" + OchChainLogManager.writeChainLog("滑动出发", changeInfo) + CallerLogger.d(TAG, "滑动出发:$changeInfo") + // 开始任务成功 + return@flatMap Observable.just(true) + } + + + } + + override fun arriveStation(seq: Int, siteId: Long, taskId: Long): Observable? { + // 开始站点:leaving true->false drivingStatus 2->1 + return Observable.just(taskId) + .flatMap { + LineManager.getStations { start, end -> + if (currentTask != null && currentTask!!.taskId != null) { + currentTask?.let { task -> + if (task.taskId != null && task.lineId != null) { + TaskSiteDb.updateDrivingStatusAndLeave( + task.taskId!!, + start.siteId.toLong(), + TaskSiteDataBean.drivingStatusPassed, + false + ) + // 设置到站任务 + LineManager.getLineInfo { lineInfo -> + EventDb.saveEventTaskArriveSite( + task.shiftsId ?: 0L, + task.taskId!!, + task.lineId!!, + end.siteId.toLong(), + end.seq, + task.taskStartTime, + lineInfo.lineName, + task.taskDate + ) + } + } + } + } else { + OchChainLogManager.writeChainLog( + "到站_数据更新_error", + "task:${currentTask}__taskId:${currentTask?.taskId}" + ) + CallerLogger.d(TAG, "到站_数据更新_error:task:${currentTask}__taskId:${currentTask?.taskId}") + } + // 结束站点: drivingStatus 3-2 + if (currentTask != null && currentTask!!.taskId != null) { + currentTask?.taskId?.let { taskId -> + TaskSiteDb.updateDrivingStatus( + taskId, + end.siteId.toLong(), + TaskSiteDataBean.drivingStatusCurrent + ) + } + } else { + OchChainLogManager.writeChainLog( + "到站_数据更新_error", + "task:${currentTask}__taskId:${currentTask?.taskId}" + ) + CallerLogger.d(TAG, "到站_数据更新_error:task:${currentTask}__taskId:${currentTask?.taskId}") + } + val changeInfo = + "taskId:${currentTask?.taskId}--lineId:${currentTask?.lineId}--currentStationName:${start.name}--finalNextStationName:${end.name}" + OchChainLogManager.writeChainLog("到站", changeInfo) + CallerLogger.d(TAG, "到站:$changeInfo") + } + return@flatMap Observable.just(true) + } + + + } + + override fun endTask(shiftsId: Long, taskId: Long): Observable? { + return Observable.just(taskId).flatMap { + currentTask?.let { task -> + if (task.taskId != null && task.lineId != null) { + TaskDb.endTask(task.taskId!!) + LineManager.getLineInfo { lineInfo -> + EventDb.saveEventTaskEnd(shiftsId, task.taskId!!, task.lineId!!, task.taskStartTime, lineInfo.lineName, task.taskDate + ?: 0L) + } + } + } + return@flatMap Observable.just(true) + } + } + + override fun endTaskByOther(taskId: Long) { + TaskDb.endTaskByOther(taskId) + } + + override fun queryCarExecutableTaskList( + ochCommonServiceCallback: OchCommonServiceCallback + ) { + weakNetInterface?.queryCarExecutableTaskList(context, ochCommonServiceCallback) + } + + override fun queryPointsByLineIds(lines: MutableList): Observable>? { + val request = QueryPointRequest(LoginStatusManager.getOchBizInfo()?.businessType + ?: 0, lines) + return weakNetInterface?.queryPointsByLinesId(context, request) + } + + override fun reportCabinEvent( + context: Context?, + data: ShuttleEventRequest?, + callback: OchCommonServiceCallback? + ) { + weakNetInterface?.reportCabinEvent(context, data, callback) + } + + override fun haveRunningTask(): Boolean { + if (LineModel.currentTask == null) { + return false + } else { + return true + } + } + + override fun release() { + weakNetInterface = null + CallerLogger.d(TAG, "重置 weakNetInterface") + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/NetInterface.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/NetInterface.java new file mode 100644 index 0000000000..d4b0ea82e6 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/NetInterface.java @@ -0,0 +1,71 @@ +package com.mogo.och.unmanned.repository.net; + +import android.content.Context; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.common.module.network.OchCommonServiceCallback; +import com.mogo.och.data.bean.BusRoutesResult; +import com.mogo.och.unmanned.bean.request.QueryPointRequest; +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest; +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse; +import com.mogo.och.unmanned.bean.response.PointResponse; +import com.mogo.och.unmanned.repository.db.bean.LineDataBean; +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean; +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest; +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse; + +import java.util.ArrayList; +import java.util.List; + +import io.reactivex.Observable; + +public interface NetInterface { + + default Observable switchLine(long taskId) { + return null; + } + + default Observable endTask(long taskId) { + return Observable.just(true); + } + + default Observable leaveStation(int seq, long siteId, long taskId, long writeVersion) { + return Observable.just(true); + } + + default Observable arriveSiteStation(int seq, long siteId, long taskId, long writeVersion) { + return Observable.just(true); + } + + default Observable> queryBusLines() { + return Observable.just(new ArrayList<>()); + } + + default Observable> queryBusTaskByLineId(long lineId) { + return Observable.just(new ArrayList<>()); + } + + + default Observable queryBusRoutes() { + return Observable.just(new BusRoutesResult()); + } + + default Observable writeOffCount(Context context, Long taskId, Long siteId) { + return Observable.just(0); + } + + default Observable writeOffTicket(Context context, + PassengerWriteOffRequest ticketInfo) { + return Observable.just(new PassengerWriteOffResponse.Result("", 0, "", 0L, 0L)); + } + + default void queryCarExecutableTaskList(Context context, OchCommonServiceCallback callback) { + } + + default void reportCabinEvent(Context context, ShuttleEventRequest data, OchCommonServiceCallback callback) { + } + + default Observable> queryPointsByLinesId(Context context, QueryPointRequest data) { + return Observable.just(new ArrayList<>()); + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusCloseTaskRequest.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusCloseTaskRequest.java new file mode 100644 index 0000000000..2664735bc6 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusCloseTaskRequest.java @@ -0,0 +1,24 @@ +package com.mogo.och.unmanned.repository.net.bean.request; + +import com.mogo.commons.storage.SharedPrefsMgr; +import com.mogo.och.common.module.utils.DateTimeUtil; + +/** + * 中止/结束任务请求 + */ +public class BusCloseTaskRequest { + + private String sn; + private long taskId; + private long writeVersion; + + public BusCloseTaskRequest(long taskId) { + this.sn = SharedPrefsMgr.getInstance().getSn(); + this.taskId = taskId; + this.writeVersion = DateTimeUtil.getCurrentTimeStamp(); + } + + public String getSn() { + return sn; + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusResetDrivingLineRequest.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusResetDrivingLineRequest.java new file mode 100644 index 0000000000..c880a3ee7c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusResetDrivingLineRequest.java @@ -0,0 +1,20 @@ +package com.mogo.och.unmanned.repository.net.bean.request; + +import com.mogo.commons.storage.SharedPrefsMgr; +import com.mogo.och.common.module.utils.DateTimeUtil; + +/** + * @author: wangmingjun + * @date: 2021/10/18 + */ +public class BusResetDrivingLineRequest { + public String sn; + public Long taskId; //切换到的线路id + public long writeVersion; //更新时间戳 + + public BusResetDrivingLineRequest(Long taskId) { + this.sn = SharedPrefsMgr.getInstance().getSn(); + this.taskId = taskId; + this.writeVersion = DateTimeUtil.getCurrentTimeStamp(); + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusRoutePlanningUpdateReqBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusRoutePlanningUpdateReqBean.kt new file mode 100644 index 0000000000..12feba2b27 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusRoutePlanningUpdateReqBean.kt @@ -0,0 +1,16 @@ +package com.mogo.och.unmanned.repository.net.bean.request + +/** + * Created by pangfan on 2021/8/19 + * + * 订单状态更新请求数据结构 + */ +class BusRoutePlanningUpdateReqBean( + var sn: String, var lineId: Int, var startSiteId: Int, + var endSiteId: Int, var points: List +) { + data class Result( + var latitude: Double? = null, + var longitude: Double? = null + ) +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusUpdateSiteStatusRequest.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusUpdateSiteStatusRequest.java new file mode 100644 index 0000000000..d4424b1bc9 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/BusUpdateSiteStatusRequest.java @@ -0,0 +1,26 @@ +package com.mogo.och.unmanned.repository.net.bean.request; + +import com.mogo.commons.storage.SharedPrefsMgr; + +/** + * @author congtaowang + * @since 2021/3/22 + *

+ * 小巴车运营状态请求参数 + */ +public class BusUpdateSiteStatusRequest { + + public String sn; + public long taskId; + public int seq;//站点序号 + public long siteId;//站点id + public long writeVersion; //更新时间戳 + + public BusUpdateSiteStatusRequest(long taskId, long siteId, int seq, long writeVersion) { + this.sn = SharedPrefsMgr.getInstance().getSn(); + this.seq = seq; + this.siteId = siteId; + this.taskId = taskId; + this.writeVersion = writeVersion; + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/CarHeartbeatReqBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/CarHeartbeatReqBean.kt new file mode 100644 index 0000000000..48b71bbcc3 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/CarHeartbeatReqBean.kt @@ -0,0 +1,17 @@ +package com.mogo.och.unmanned.repository.net.bean.request + +import com.mogo.och.unmanned.constant.BusConst +import java.util.UUID + +/** + * Created on 2021/9/16 + * + * 上传车机心跳信息请求数据 + */ +class CarHeartbeatReqBean( + var sn: String, //经度 + var lon: Double, //纬度 + var lat: Double, + var msgId: String = UUID.randomUUID().toString(), //心跳信息唯一标识 + var interval: Int = (BusConst.LOOP_PERIOD_60S / 1000).toInt() //上报间隔,单位秒,非必传,默认60秒 +) diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/PassengerWriteOffRequest.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/PassengerWriteOffRequest.java new file mode 100644 index 0000000000..48df83fbe1 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/PassengerWriteOffRequest.java @@ -0,0 +1,50 @@ +package com.mogo.och.unmanned.repository.net.bean.request; + +public +/** + * @author congtaowang + * @since 2021/3/22 + * + * 根据车机行驶线路站点信息 + */ +class PassengerWriteOffRequest { + + private String sn; + private String orderNo; + private String uid; + + public PassengerWriteOffRequest(String orderNo, String uid) { + this.orderNo = orderNo; + this.uid = uid; + } + + public PassengerWriteOffRequest(String sn, String orderNo, String uid) { + this.sn = sn; + this.orderNo = orderNo; + this.uid = uid; + } + + public String getSn() { + return sn; + } + + public void setSn(String sn) { + this.sn = sn; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/WriteOffCountReqBean.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/WriteOffCountReqBean.kt new file mode 100644 index 0000000000..3bb5b1ea67 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/request/WriteOffCountReqBean.kt @@ -0,0 +1,3 @@ +package com.mogo.och.unmanned.repository.net.bean.request + +data class WriteOffCountReqBean(val sn: String, val taskId: Long, val siteId: Long) \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/BusQueryLineTaskResponse.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/BusQueryLineTaskResponse.java new file mode 100644 index 0000000000..d89c7eb053 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/BusQueryLineTaskResponse.java @@ -0,0 +1,14 @@ +package com.mogo.och.unmanned.repository.net.bean.response; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean; + +import java.util.List; + +/** + * @author: wangmingjun + * @date: 2022/2/9 + */ +public class BusQueryLineTaskResponse extends BaseData { + public List data; +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/BusQueryLinesResponse.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/BusQueryLinesResponse.java new file mode 100644 index 0000000000..37009400eb --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/BusQueryLinesResponse.java @@ -0,0 +1,14 @@ +package com.mogo.och.unmanned.repository.net.bean.response; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.unmanned.repository.db.bean.LineDataBean; + +import java.util.List; + +/** + * @author: wangmingjun + * @date: 2022/2/9 + */ +public class BusQueryLinesResponse extends BaseData { + public List data; +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/PassengerWriteOffResponse.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/PassengerWriteOffResponse.kt new file mode 100644 index 0000000000..698511274f --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/bean/response/PassengerWriteOffResponse.kt @@ -0,0 +1,14 @@ +package com.mogo.och.unmanned.repository.net.bean.response + +import com.mogo.eagle.core.data.BaseData + + +data class PassengerWriteOffResponse(val data: Result?) : BaseData() { + data class Result( + val phone: String?, + val ticketSize: Int?, + val ticketName: String?, + val remainingTimes: Long?,//剩余次数, + val businessTime: Long?,//业务时间 + ) +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/exception/NetException.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/exception/NetException.kt new file mode 100644 index 0000000000..09c2f0257e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/exception/NetException.kt @@ -0,0 +1,6 @@ +package com.mogo.och.unmanned.repository.net.exception + +class NetException : RuntimeException { + constructor() : super() + constructor(message: String?) : super(message) +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/bus/DaliBusServiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/bus/DaliBusServiceManager.kt new file mode 100644 index 0000000000..c0fe18b894 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/bus/DaliBusServiceManager.kt @@ -0,0 +1,142 @@ +package com.mogo.och.unmanned.repository.net.project.dali.bus + +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.common.module.network.OchCommonNet +import com.mogo.och.common.module.network.interceptor.transformTry +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.bean.request.BusCloseTaskRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusResetDrivingLineRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusUpdateSiteStatusRequest +import io.reactivex.Observable + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +object DaliBusServiceManager : NetInterface { + + private val mService: IDaliBusApiService = + MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create( + IDaliBusApiService::class.java + ) + + + /** + * 查询小巴车当前任务 + */ + override fun queryBusRoutes(): Observable? { + return mService.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusQueryLineStationsRequest() + ).transformTry() + .flatMap(OchCommonNet("saas bus queryBusRoutes", false)) + .flatMap { + Observable.just(it.data ?: BusRoutesResult()) + } + } + + /** + * 重置线路站点 + * @param taskId + */ + override fun switchLine( + taskId: Long, + ): Observable? { + return mService.switchLine( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusResetDrivingLineRequest(taskId) + ).transformTry() + .flatMap(OchCommonNet("switchLine", false)) + .flatMap { + Observable.just(true) + } + } + + /** + * 正常结束任务 + * @param taskId + */ + override fun endTask(taskId: Long): Observable? { + return mService.endTask( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusCloseTaskRequest(taskId) + ).transformTry() + .flatMap(OchCommonNet("endTask", true)) + .flatMap { + Observable.just(true) + } + } + + /** + * 离站上报 + * @param seq + * @param siteId + */ + override fun leaveStation(seq: Int, siteId: Long, taskId: Long, writeVersion: Long): Observable? { + return mService.leaveStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion) + ).transformTry() + .flatMap(OchCommonNet("leaveStation", false)) + .flatMap { + Observable.just(true) + } + } + + /** + * 到站更新站点状态 + * @param seq + * @param siteId + */ + override fun arriveSiteStation( + seq: Int, siteId: Long, taskId: Long, writeVersion: Long, + ): Observable? { + return mService.arriveSiteStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion) + ) + .transformTry() + .flatMap(OchCommonNet("arriveSiteStation", false)) + .flatMap { + Observable.just(true) + } + } + + override fun queryBusLines(): Observable?> { + return mService.queryBusLines( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + SharedPrefsMgr.getInstance().sn + ).transformTry() + .flatMap(OchCommonNet("queryBusLines", false)) + .flatMap { + Observable.just(it.data) + } + + } + + override fun queryBusTaskByLineId(lineId: Long): Observable?> { + return mService.queryBusTaskByLineId( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + lineId + ).transformTry() + .flatMap(OchCommonNet("queryBusLines", false)) + .flatMap { + Observable.just(it.data) + } + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/bus/IDaliBusApiService.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/bus/IDaliBusApiService.kt new file mode 100644 index 0000000000..dfcdcae399 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/bus/IDaliBusApiService.kt @@ -0,0 +1,151 @@ +package com.mogo.och.unmanned.repository.net.project.dali.bus + +import com.mogo.eagle.core.data.BaseData +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.bean.response.BusRoutesResponse +import com.mogo.och.unmanned.bean.response.WriteOffCountResponse +import com.mogo.och.unmanned.repository.net.bean.request.BusCloseTaskRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusResetDrivingLineRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusRoutePlanningUpdateReqBean +import com.mogo.och.unmanned.repository.net.bean.request.BusUpdateSiteStatusRequest +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest +import com.mogo.och.unmanned.repository.net.bean.response.BusQueryLineTaskResponse +import com.mogo.och.unmanned.repository.net.bean.response.BusQueryLinesResponse +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse +import io.reactivex.Observable +import retrofit2.http.Body +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.Headers +import retrofit2.http.POST +import retrofit2.http.Query + +/** + * 小巴车相关接口 + * + * @author tongchenfei + * + * + * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + */ +interface IDaliBusApiService { + /** + * 根据车机坐标获取所在区域全部站点信息 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers("Content-Type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/line/v2/driver/bus/lineDataWithDriver/query") + fun queryBusRoutes(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusQueryLineStationsRequest?): Observable + + /** + * @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的 + * @return 返回值是重置后的车站列表 + * 开始路线 + */ + @Headers("Content-Type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask") + fun switchLine(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusResetDrivingLineRequest?): Observable + + /** + * 离站,通知服务器 + * @param request + * @return + */ + @Headers("Content-Type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/leave") + fun leaveStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable + + /** + * 到站 更新到站信息 + * @param request + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/arrive") + fun arriveSiteStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable + + + /** + * 查询车辆配置的所有路线 + * @param appId + * @param ticket + * @param sn + * @return + */ + @GET("/autopilot-car-hailing/line/v2/driver/bus/bindLine/query") + fun queryBusLines(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("sn") sn: String?): Observable + + /** + * 查询路线当天的任务 + * @param appId + * @param ticket + * @param lineId 线路id + * @return + */ + @GET("/autopilot-car-hailing/line/v2/driver/bus/task/query") + fun queryBusTaskByLineId(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("lineId") lineId: Long?): Observable + + + /** + * 上传轨迹信息 + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/location/v2/driver/bus/saveLineCoordinate") + fun updateOrderRoute( + @Header("appId") appId: String?, + @Header("ticket") ticket: String?, + @Body data: BusRoutePlanningUpdateReqBean? + ): Observable + + /** + * 中止任务 + * @param appId + * @param ticket + * @param data + * @return + */ + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/abortTask") + fun abortTask( + @Header("appId") appId: String?, + @Header("ticket") ticket: String?, + @Body data: BusCloseTaskRequest? + ): Observable + + /** + * 任务正常跑完结束 + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endTask") + fun endTask(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body data: BusCloseTaskRequest?): Observable + + + /** + * 任务正常跑完结束 + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/och-bus-cabin/cab/flow/v1/bus/driver/endTask") + fun writeOffCount(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("taskId") taskId: Long, @Query("siteId") siteId: Long): Observable + + /** + * 核销接口 + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/och-vehicle/api/scanner/device/writeOff") + fun daliwriteOffTicket(@Header("appId") appId: String, @Header("ticket") ticket: String, @Body request: PassengerWriteOffRequest): Observable + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/shuttle/DaliShuttleServiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/shuttle/DaliShuttleServiceManager.kt new file mode 100644 index 0000000000..1545c57ed5 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/shuttle/DaliShuttleServiceManager.kt @@ -0,0 +1,117 @@ +package com.mogo.och.unmanned.repository.net.project.dali.shuttle + +import android.content.Context +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.common.module.manager.cache.OchSPManager +import com.mogo.och.common.module.network.OchCommonNet +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.common.module.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.network.interceptor.transformIoTry +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse +import io.reactivex.Observable + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +object DaliShuttleServiceManager : NetInterface { + + private val mService: IDaliShuttleApiService = + MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create( + IDaliShuttleApiService::class.java + ) + + + /** + * 查询小巴车当前任务 + */ + override fun queryBusRoutes(): Observable? { + //获取当前高德坐标 + return mService.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusQueryLineStationsRequest() + ).transformIoTry() + .flatMap(OchCommonNet("saas shuttle queryBusRoutes", false)) + .flatMap { + Observable.just(it.data ?: BusRoutesResult()) + } + } + + /** + * 只发生在大理和saas环境 查询当前站点核销的人数 + */ + override fun writeOffCount(context: Context?, taskId: Long?, siteId: Long?): Observable { + return mService.writeOffCount( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + taskId?.toString(), + siteId?.toString() + ) + .flatMap(OchCommonNet("saas shuttle writeOffCount", false)) + .flatMap { + Observable.just(it.data ?: 0) + } + } + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + override fun queryCarExecutableTaskList( + context: Context, + callback: OchCommonServiceCallback? + ) { + mService.queryCarExecutableTaskList( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + SharedPrefsMgr.getInstance().sn, + ) + .transformIoTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryCarExecutableTaskList")) + } + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + override fun reportCabinEvent( + context: Context, + data: ShuttleEventRequest, + callback: OchCommonServiceCallback?, + ) { + mService.reportCabinEvent( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + data, + ) + .subscribe(OchCommonSubscribeImpl(context, callback, "reportCabinEvent")) + } + + override fun writeOffTicket( + context: Context, + ticketInfo: PassengerWriteOffRequest, + ): Observable? { + ticketInfo.sn = OchSPManager.getSn() + return mService.daliwriteOffTicket( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + ticketInfo + ) + .transformIoTry() + .flatMap(OchCommonNet("dali shuttle writeOffCount", false)) + .flatMap { + Observable.just(it.data) + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/shuttle/IDaliShuttleApiService.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/shuttle/IDaliShuttleApiService.java new file mode 100644 index 0000000000..a734216d11 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/dali/shuttle/IDaliShuttleApiService.java @@ -0,0 +1,68 @@ +package com.mogo.och.unmanned.repository.net.project.dali.shuttle; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest; +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest; +import com.mogo.och.unmanned.bean.response.BusRoutesResponse; +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse; +import com.mogo.och.unmanned.bean.response.WriteOffCountResponse; +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest; +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse; + +import io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * 小巴车相关接口 + * + * @author tongchenfei + *

+ * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + */ +public interface IDaliShuttleApiService { + + /** + * 查询当前运行任务 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/business/v1/driver/lineDataWithDriver/query") + Observable queryBusRoutes(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request); + + /** + * 查询当前站点核销的人数 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @GET("och-shuttle-cabin/api/business/v1/task/writeOffCount") + Observable 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"}) + @POST("/och-vehicle/api/scanner/device/writeOff") + Observable daliwriteOffTicket(@Header("appId") String appId, @Header("ticket") String ticket, @Body PassengerWriteOffRequest request); + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @GET("/och-shuttle-cabin/api/flow/v1/queryCarExecutableTaskList") + Observable queryCarExecutableTaskList(@Header("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/flow/v1/reportCabinEvent") + Observable reportCabinEvent(@Header("appId") String appId, @Header("ticket") String ticket, @Body ShuttleEventRequest request); + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/bus/IMogoBusApiService.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/bus/IMogoBusApiService.kt new file mode 100644 index 0000000000..0b40a84d3c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/bus/IMogoBusApiService.kt @@ -0,0 +1,129 @@ +package com.mogo.och.unmanned.repository.net.project.mogo.bus + +import com.mogo.eagle.core.data.BaseData +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.bean.response.BusRoutesResponse +import com.mogo.och.unmanned.repository.net.bean.request.BusCloseTaskRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusResetDrivingLineRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusRoutePlanningUpdateReqBean +import com.mogo.och.unmanned.repository.net.bean.request.BusUpdateSiteStatusRequest +import com.mogo.och.unmanned.repository.net.bean.request.CarHeartbeatReqBean +import com.mogo.och.unmanned.repository.net.bean.response.BusQueryLineTaskResponse +import com.mogo.och.unmanned.repository.net.bean.response.BusQueryLinesResponse +import io.reactivex.Observable +import retrofit2.http.Body +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.Headers +import retrofit2.http.POST +import retrofit2.http.Query + +/** + * 小巴车相关接口 + * + * @author tongchenfei + * + * + * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + */ +interface IMogoBusApiService { + /** + * 根据车机坐标获取所在区域全部站点信息 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers("Content-Type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/line/v2/driver/bus/lineDataWithDriver/query") + fun queryBusRoutes(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusQueryLineStationsRequest?): Observable + + /** + * @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的 + * @return 返回值是重置后的车站列表 + * 开始路线 + */ + @Headers("Content-Type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/startTask") + fun switchLine(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusResetDrivingLineRequest?): Observable + + /** + * 离站,通知服务器 + * @param request + * @return + */ + @Headers("Content-Type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/leave") + fun leaveStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable + + /** + * 到站 更新到站信息 + * @param request + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/arrive") + fun arriveSiteStation(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body request: BusUpdateSiteStatusRequest?): Observable + + + /** + * 车机端上传心跳数据(只在出车状态时上传):包含高德坐标系经纬度 + * @param data + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/location/v2/driver/bus/heartbeat") + fun runCarHeartbeat( + @Header("appId") appId: String?, + @Header("ticket") ticket: String?, + @Body data: CarHeartbeatReqBean? + ): Observable + + /** + * 查询车辆配置的所有路线 + * @param appId + * @param ticket + * @param sn + * @return + */ + @GET("/autopilot-car-hailing/line/v2/driver/bus/bindLine/query") + fun queryBusLines(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("sn") sn: String?): Observable + + /** + * 查询路线当天的任务 + * @param appId + * @param ticket + * @param lineId 线路id + * @return + */ + @GET("/autopilot-car-hailing/line/v2/driver/bus/task/query") + fun queryBusTaskByLineId(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Query("lineId") lineId: Long?): Observable + + + /** + * 上传轨迹信息 + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/location/v2/driver/bus/saveLineCoordinate") + fun updateOrderRoute( + @Header("appId") appId: String?, + @Header("ticket") ticket: String?, + @Body data: BusRoutePlanningUpdateReqBean? + ): Observable + + /** + * 任务正常跑完结束 + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers("Content-type:application/json;charset=UTF-8") + @POST("/autopilot-car-hailing/cab/flow/v1/bus/driver/bus/endTask") + fun endTask(@Header("appId") appId: String?, @Header("ticket") ticket: String?, @Body data: BusCloseTaskRequest?): Observable + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/bus/MogoBusServiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/bus/MogoBusServiceManager.kt new file mode 100644 index 0000000000..61c01921cc --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/bus/MogoBusServiceManager.kt @@ -0,0 +1,148 @@ +package com.mogo.och.unmanned.repository.net.project.mogo.bus + +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.common.module.network.OchCommonNet +import com.mogo.och.common.module.network.interceptor.transformTry +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.bean.request.BusCloseTaskRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusResetDrivingLineRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusUpdateSiteStatusRequest +import io.reactivex.Observable + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +class MogoBusServiceManager : NetInterface { + + private val mService: IMogoBusApiService = + MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create( + IMogoBusApiService::class.java + ) + + + /** + * 查询小巴车当前任务 + */ + override fun queryBusRoutes(): Observable? { + return mService.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusQueryLineStationsRequest() + ).transformTry() + .flatMap(OchCommonNet("mogo/dali bus queryBusRoutes", false)) + .flatMap { + Observable.just(it.data ?: BusRoutesResult()) + } + } + + /** + * 重置线路站点 + * @param taskId + */ + override fun switchLine( + taskId: Long, + ): Observable? { + return mService.switchLine( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusResetDrivingLineRequest(taskId) + ).transformTry() + .flatMap(OchCommonNet("switchLine", false)) + .flatMap { + Observable.just(true) + } + } + + /** + * 正常结束任务 + * @param taskId + */ + override fun endTask(taskId: Long): Observable? { + return mService.endTask( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusCloseTaskRequest(taskId) + ).transformTry() + .flatMap(OchCommonNet("endTask", true)) + .flatMap { + Observable.just(true) + } + } + + /** + * 离站上报 + * @param seq + * @param siteId + */ + override fun leaveStation( + seq: Int, + siteId: Long, + taskId: Long, + writeVersion: Long, + ): Observable? { + return mService.leaveStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion) + ).transformTry() + .flatMap(OchCommonNet("leaveStation", false)) + .flatMap { + Observable.just(true) + } + } + + /** + * 到站更新站点状态 + * @param seq + * @param siteId + */ + override fun arriveSiteStation( + seq: Int, siteId: Long, taskId: Long, writeVersion: Long, + ): Observable? { + return mService.arriveSiteStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion) + ) + .transformTry() + .flatMap(OchCommonNet("arriveSiteStation", false)) + .flatMap { + Observable.just(true) + } + } + + + override fun queryBusLines(): Observable?> { + return mService.queryBusLines( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + SharedPrefsMgr.getInstance().sn + ).transformTry() + .flatMap(OchCommonNet("queryBusLines", false)) + .flatMap { + Observable.just(it.data) + } + + } + + override fun queryBusTaskByLineId(lineId: Long): Observable?> { + return mService.queryBusTaskByLineId( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + lineId + ).transformTry() + .flatMap(OchCommonNet("queryBusLines", false)) + .flatMap { + Observable.just(it.data) + } + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/shuttle/IMogoShuttleApiService.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/shuttle/IMogoShuttleApiService.java new file mode 100644 index 0000000000..546f095fed --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/shuttle/IMogoShuttleApiService.java @@ -0,0 +1,101 @@ +package com.mogo.och.unmanned.repository.net.project.mogo.shuttle; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest; +import com.mogo.och.unmanned.bean.response.BusRoutesResponse; +import com.mogo.och.unmanned.repository.net.bean.request.BusCloseTaskRequest; +import com.mogo.och.unmanned.repository.net.bean.request.BusResetDrivingLineRequest; +import com.mogo.och.unmanned.repository.net.bean.request.BusUpdateSiteStatusRequest; +import com.mogo.och.unmanned.repository.net.bean.response.BusQueryLineTaskResponse; +import com.mogo.och.unmanned.repository.net.bean.response.BusQueryLinesResponse; + +import io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * 小巴车相关接口 + * + * @author tongchenfei + *

+ */ +public interface IMogoShuttleApiService { + /** + * 查询当前运行任务 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/business/v1/driver/lineDataWithDriver/query") + Observable queryBusRoutes(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request); + + /** + * @param request 请求参数{"destLine":1,"sn":"F803EB2046PZD00229"} 这个接口是重置bus线路的, 不是重置线路中站点的 + * @return 返回值是重置后的车站列表 + * 开始路线 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/flow/v1/driver/startTask") + Observable switchLine(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusResetDrivingLineRequest request); + + /** + * 离站,通知服务器 + * + * @param request + * @return + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/flow/v1/driver/leave") + Observable leaveStation(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusUpdateSiteStatusRequest request); + + /** + * 到站 更新到站信息 + * + * @param request + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/flow/v1/driver/arrive") + Observable 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 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 queryBusTaskByLineId(@Header("appId") String appId, @Header("ticket") String ticket, @Query("lineId") Long lineId); + + /** + * 任务正常跑完结束 + * + * @param appId + * @param ticket + * @param data + * @return + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/flow/v1/driver/endTask") + Observable endTask(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusCloseTaskRequest data); + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/shuttle/MogoShuttleServiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/shuttle/MogoShuttleServiceManager.kt new file mode 100644 index 0000000000..7e64be9de7 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/mogo/shuttle/MogoShuttleServiceManager.kt @@ -0,0 +1,158 @@ +package com.mogo.och.unmanned.repository.net.project.mogo.shuttle + +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.common.module.network.OchCommonNet +import com.mogo.och.common.module.network.interceptor.transformTry +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.bean.request.BusCloseTaskRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusResetDrivingLineRequest +import com.mogo.och.unmanned.repository.net.bean.request.BusUpdateSiteStatusRequest +import io.reactivex.Observable + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +class MogoShuttleServiceManager : NetInterface { + + private val mService: IMogoShuttleApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create( + IMogoShuttleApiService::class.java + ) + + + /** + * 查询小巴车当前任务 + * @param context + * @param callback + */ + override fun queryBusRoutes(): Observable? { + return mService.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusQueryLineStationsRequest() + ).transformTry() + .flatMap(OchCommonNet("mogo/dali shuttle queryBusRoutes", false)) + .flatMap { + Observable.just(it.data ?: BusRoutesResult()) + } + } + + /** + * 重置线路站点 + * @param context + * @param taskId + * @param callback + */ + override fun switchLine( + taskId: Long, + ): Observable? { + return mService.switchLine( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusResetDrivingLineRequest(taskId) + ).transformTry() + .flatMap(OchCommonNet("switchLine", false)) + .flatMap { + Observable.just(true) + } + } + + /** + * 正常结束任务 + * @param context + * @param taskId + * @param callback + */ + override fun endTask(taskId: Long): Observable? { + return mService.endTask( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusCloseTaskRequest(taskId) + ).transformTry() + .flatMap(OchCommonNet("endTask", true)) + .flatMap { + Observable.just(true) + } + } + + /** + * 离站上报 + * @param context + * @param seq + * @param siteId + * @param callback + */ + override fun leaveStation( + seq: Int, + siteId: Long, + taskId: Long, + writeVersion: Long, + ): Observable? { + return mService.leaveStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion) + ).transformTry() + .flatMap(OchCommonNet("leaveStation", false)) + .flatMap { + Observable.just(true) + } + } + + /** + * 到站更新站点状态 + * @param context + * @param seq + * @param siteId + * @param callback + */ + override fun arriveSiteStation( + seq: Int, siteId: Long, taskId: Long, writeVersion: Long, + ): Observable? { + return mService.arriveSiteStation( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusUpdateSiteStatusRequest(taskId, siteId, seq, writeVersion) + ) + .transformTry() + .flatMap(OchCommonNet("arriveSiteStation", false)) + .flatMap { + Observable.just(true) + } + } + + + override fun queryBusLines(): Observable?> { + return mService.queryBusLines( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + SharedPrefsMgr.getInstance().sn + ).transformTry() + .flatMap(OchCommonNet("queryBusLines", false)) + .flatMap { + Observable.just(it.data) + } + + } + + override fun queryBusTaskByLineId( + lineId: Long): Observable?> { + return mService.queryBusTaskByLineId( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + lineId + ).transformTry() + .flatMap(OchCommonNet("queryBusLines", false)) + .flatMap { + Observable.just(it.data) + } + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/bus/ISaasBusApiService.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/bus/ISaasBusApiService.java new file mode 100644 index 0000000000..9b3d069be2 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/bus/ISaasBusApiService.java @@ -0,0 +1,74 @@ +package com.mogo.och.unmanned.repository.net.project.saas.bus; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.unmanned.bean.request.QueryPointRequest; +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest; +import com.mogo.och.unmanned.bean.response.BusRoutesResponse; +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse; +import com.mogo.och.unmanned.bean.response.PointsResponse; +import com.mogo.och.unmanned.bean.response.WriteOffCountResponse; +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest; +import com.mogo.och.unmanned.repository.net.bean.request.WriteOffCountReqBean; +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse; + +import io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * 小巴车相关接口 + * + * @author tongchenfei + *

+ * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + */ +public interface ISaasBusApiService { + + /** + * 查询当前运行任务 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @GET("/och-bus-cabin/api/business/v1/driver/bus/lineDataWithDriver/query") + Observable queryBusRoutes(@Header("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + /** + * 查询当前站点核销的人数 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/api/car/v2/task/site/writeOffCount") + Observable writeOffCount(@Header("appId") String appId, @Header("ticket") String ticket, @Body WriteOffCountReqBean writeOffCountReqBean); + + /** + * 同步核销接口 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/api/car/v2/device/writeOff") + Observable saaswriteOffTicket(@Header("appId") String appId, @Header("ticket") String ticket, @Body PassengerWriteOffRequest request); + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @GET("/och-vehicle/cabin/queryCarExecutableTaskList") + Observable queryCarExecutableTaskList(@Header("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/cabin/reportCabinEvent") + Observable reportCabinEvent(@Header("appId") String appId, @Header("ticket") String ticket, @Body ShuttleEventRequest request); + + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-contrail/contrail/queryCabinContrailByLines") + Observable queryCabinContrailByLines(@Header("appId") String appId, @Header("ticket") String ticket, @Body QueryPointRequest request); + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/bus/SaasBusServiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/bus/SaasBusServiceManager.kt new file mode 100644 index 0000000000..9262d32428 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/bus/SaasBusServiceManager.kt @@ -0,0 +1,100 @@ +package com.mogo.och.unmanned.repository.net.project.saas.bus + +import android.content.Context +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.common.module.network.OchCommonNet +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.common.module.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.network.interceptor.transformIoTry +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.unmanned.bean.request.QueryPointRequest +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.repository.net.NetInterface +import io.reactivex.Observable + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +object SaasBusServiceManager : NetInterface { + + private val mService: ISaasBusApiService = + MoGoRetrofitFactory.getInstance(OchCommonConst.getBaseUrl()).create( + ISaasBusApiService::class.java + ) + + + /** + * 查询小巴车当前任务 + * @param context + * @param callback + */ + override fun queryBusRoutes(): Observable? { + //获取当前高德坐标 + return mService.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + SharedPrefsMgr.getInstance().getSn() + ).transformIoTry() + .flatMap(OchCommonNet("queryBusRoutes", false)) + .flatMap { + Observable.just(it.data ?: BusRoutesResult()) + } + } + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + override fun queryCarExecutableTaskList( + context: Context, + callback: OchCommonServiceCallback? + ) { + mService.queryCarExecutableTaskList( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + SharedPrefsMgr.getInstance().sn, + ) + .transformIoTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryCarExecutableTaskList")) + } + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + override fun reportCabinEvent( + context: Context, + data: ShuttleEventRequest, + callback: OchCommonServiceCallback?, + ) { + mService.reportCabinEvent( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + data, + ) + .subscribe(OchCommonSubscribeImpl(context, callback, "reportCabinEvent")) + } + + override fun queryPointsByLinesId( + context: Context?, + data: QueryPointRequest? + ): Observable>? { + return mService.queryCabinContrailByLines( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + data, + ) + .transformIoTry() + .flatMap(OchCommonNet("queryPointsByLinesId", false)) + .flatMap { + Observable.just(it.data ?: mutableListOf()) + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/scheduled/ISaasScheduledApiService.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/scheduled/ISaasScheduledApiService.java new file mode 100644 index 0000000000..9bab18782e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/scheduled/ISaasScheduledApiService.java @@ -0,0 +1,75 @@ +package com.mogo.och.unmanned.repository.net.project.saas.scheduled; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest; +import com.mogo.och.unmanned.bean.request.QueryPointRequest; +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest; +import com.mogo.och.unmanned.bean.response.BusRoutesResponse; +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse; +import com.mogo.och.unmanned.bean.response.PointsResponse; +import com.mogo.och.unmanned.bean.response.WriteOffCountResponse; +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest; +import com.mogo.och.unmanned.repository.net.bean.request.WriteOffCountReqBean; +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse; + +import io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * 小巴车相关接口 + * + * @author tongchenfei + *

+ * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + */ +public interface ISaasScheduledApiService { + + /** + * 查询当前运行任务 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/business/v1/driver/lineDataWithDriver/query") + Observable queryBusRoutes(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request); + + /** + * 查询当前站点核销的人数 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/api/car/v2/task/site/writeOffCount") + Observable writeOffCount(@Header("appId") String appId, @Header("ticket") String ticket, @Body WriteOffCountReqBean writeOffCountReqBean); + + /** + * 同步核销接口 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/api/car/v2/device/writeOff") + Observable saaswriteOffTicket(@Header("appId") String appId, @Header("ticket") String ticket, @Body PassengerWriteOffRequest request); + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @GET("/och-vehicle/cabin/queryCarExecutableTaskList") + Observable queryCarExecutableTaskList(@Header("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/cabin/reportCabinEvent") + Observable reportCabinEvent(@Header("appId") String appId, @Header("ticket") String ticket, @Body ShuttleEventRequest request); + + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-contrail/contrail/queryCabinContrailByLines") + Observable queryCabinContrailByLines(@Header("appId") String appId, @Header("ticket") String ticket, @Body QueryPointRequest request); + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/scheduled/SaasScheduledServiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/scheduled/SaasScheduledServiceManager.kt new file mode 100644 index 0000000000..9fc72180f2 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/scheduled/SaasScheduledServiceManager.kt @@ -0,0 +1,99 @@ +package com.mogo.och.unmanned.repository.net.project.saas.scheduled + +import android.content.Context +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.common.module.manager.cache.OchSPManager +import com.mogo.och.common.module.network.OchCommonNet +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.common.module.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.network.interceptor.transformIoTry +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.bean.request.QueryPointRequest +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.repository.net.NetInterface +import io.reactivex.Observable + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +object SaasScheduledServiceManager : NetInterface { + + private val mService: ISaasScheduledApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create( + ISaasScheduledApiService::class.java + ) + + + /** + * 查询小巴车当前任务 + */ + override fun queryBusRoutes(): Observable? { + //获取当前高德坐标 + return mService.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusQueryLineStationsRequest() + ).transformIoTry() + .flatMap(OchCommonNet("queryBusRoutes", false)) + .flatMap { + Observable.just(it.data ?: BusRoutesResult()) + } + } + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + override fun queryCarExecutableTaskList( + context: Context, + callback: OchCommonServiceCallback? + ) { + mService.queryCarExecutableTaskList( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + OchSPManager.getSn() + ) + .transformIoTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryCarExecutableTaskList")) + } + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + override fun reportCabinEvent( + context: Context, + data: ShuttleEventRequest, + callback: OchCommonServiceCallback?, + ) { + mService.reportCabinEvent( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + data, + ) + .subscribe(OchCommonSubscribeImpl(context, callback, "reportCabinEvent")) + } + + override fun queryPointsByLinesId( + context: Context?, + data: QueryPointRequest? + ): Observable>? { + return mService.queryCabinContrailByLines( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + data, + ) + .transformIoTry() + .flatMap(OchCommonNet("queryPointsByLinesId", false)) + .flatMap { + Observable.just(it.data ?: mutableListOf()) + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/shuttle/ISaasShuttleApiService.java b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/shuttle/ISaasShuttleApiService.java new file mode 100644 index 0000000000..da0acbe6e7 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/shuttle/ISaasShuttleApiService.java @@ -0,0 +1,75 @@ +package com.mogo.och.unmanned.repository.net.project.saas.shuttle; + +import com.mogo.eagle.core.data.BaseData; +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest; +import com.mogo.och.unmanned.bean.request.QueryPointRequest; +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest; +import com.mogo.och.unmanned.bean.response.BusRoutesResponse; +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse; +import com.mogo.och.unmanned.bean.response.PointsResponse; +import com.mogo.och.unmanned.bean.response.WriteOffCountResponse; +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest; +import com.mogo.och.unmanned.repository.net.bean.request.WriteOffCountReqBean; +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse; + +import io.reactivex.Observable; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.http.Query; + +/** + * 小巴车相关接口 + * + * @author tongchenfei + *

+ * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072 + */ +public interface ISaasShuttleApiService { + + /** + * 查询当前运行任务 + * + * @param request 请求参数 + * @return 接口返回数据 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-shuttle-cabin/api/business/v1/driver/lineDataWithDriver/query") + Observable queryBusRoutes(@Header("appId") String appId, @Header("ticket") String ticket, @Body BusQueryLineStationsRequest request); + + /** + * 查询当前站点核销的人数 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/api/car/v2/task/site/writeOffCount") + Observable writeOffCount(@Header("appId") String appId, @Header("ticket") String ticket, @Body WriteOffCountReqBean writeOffCountReqBean); + + /** + * 同步核销接口 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/api/car/v2/device/writeOff") + Observable saaswriteOffTicket(@Header("appId") String appId, @Header("ticket") String ticket, @Body PassengerWriteOffRequest request); + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + @Headers({"Content-type:application/json;charset=UTF-8"}) + @GET("/och-vehicle/cabin/queryCarExecutableTaskList") + Observable queryCarExecutableTaskList(@Header("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn); + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-vehicle/cabin/reportCabinEvent") + Observable reportCabinEvent(@Header("appId") String appId, @Header("ticket") String ticket, @Body ShuttleEventRequest request); + + @Headers({"Content-Type:application/json;charset=UTF-8"}) + @POST("/och-contrail/contrail/queryCabinContrailByLines") + Observable queryCabinContrailByLines(@Header("appId") String appId, @Header("ticket") String ticket, @Body QueryPointRequest request); + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/shuttle/SaasShuttleServiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/shuttle/SaasShuttleServiceManager.kt new file mode 100644 index 0000000000..5e33c9871d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/net/project/saas/shuttle/SaasShuttleServiceManager.kt @@ -0,0 +1,99 @@ +package com.mogo.och.unmanned.repository.net.project.saas.shuttle + +import android.content.Context +import com.mogo.cloud.passport.MoGoAiCloudClientConfig +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.och.common.module.constant.OchCommonConst +import com.mogo.och.common.module.manager.cache.OchSPManager +import com.mogo.och.common.module.network.OchCommonNet +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.common.module.network.OchCommonSubscribeImpl +import com.mogo.och.common.module.network.interceptor.transformIoTry +import com.mogo.och.data.bean.BusRoutesResult +import com.mogo.och.unmanned.bean.request.BusQueryLineStationsRequest +import com.mogo.och.unmanned.bean.request.QueryPointRequest +import com.mogo.och.unmanned.bean.request.ShuttleEventRequest +import com.mogo.och.unmanned.bean.response.CarExecutableTaskResponse +import com.mogo.och.unmanned.bean.response.PointResponse +import com.mogo.och.unmanned.repository.net.NetInterface +import io.reactivex.Observable + +/** + * @author: wangmingjun + * @date: 2021/10/20 + */ +object SaasShuttleServiceManager : NetInterface { + + private val mService: ISaasShuttleApiService = MoGoRetrofitFactory.getInstance(OchCommonConst.getShuttleUrl()).create( + ISaasShuttleApiService::class.java + ) + + + /** + * 查询小巴车当前任务 + */ + override fun queryBusRoutes(): Observable? { + //获取当前高德坐标 + return mService.queryBusRoutes( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + BusQueryLineStationsRequest() + ).transformIoTry() + .flatMap(OchCommonNet("queryBusRoutes", false)) + .flatMap { + Observable.just(it.data ?: BusRoutesResult()) + } + } + + /** + * 同步 线路、站点、任务、自驾轨迹信息 + */ + override fun queryCarExecutableTaskList( + context: Context, + callback: OchCommonServiceCallback? + ) { + mService.queryCarExecutableTaskList( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + OchSPManager.getSn() + ) + .transformIoTry() + .subscribe(OchCommonSubscribeImpl(context, callback, "queryCarExecutableTaskList")) + } + + /** + * 上传 开始线路 滑动出发 到站 完成线路 各个任务到服务器端 + */ + override fun reportCabinEvent( + context: Context, + data: ShuttleEventRequest, + callback: OchCommonServiceCallback?, + ) { + mService.reportCabinEvent( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + data, + ) + .subscribe(OchCommonSubscribeImpl(context, callback, "reportCabinEvent")) + } + + override fun queryPointsByLinesId( + context: Context?, + data: QueryPointRequest? + ): Observable>? { + return mService.queryCabinContrailByLines( + MoGoAiCloudClientConfig.getInstance().serviceAppId, + SharedPrefsMgr.getInstance().token, + data, + ) + .transformIoTry() + .flatMap(OchCommonNet("queryPointsByLinesId", false)) + .flatMap { + Observable.just(it.data ?: mutableListOf()) + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/IWriteOffRepository.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/IWriteOffRepository.kt new file mode 100644 index 0000000000..c3d384e9b4 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/IWriteOffRepository.kt @@ -0,0 +1,29 @@ +package com.mogo.och.unmanned.repository.writeoff + +import android.content.Context +import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.unmanned.bean.WaitUploadLine +import com.mogo.och.unmanned.bean.WriteOffPassenger +import com.mogo.och.unmanned.bean.response.WriteOffCountResponse +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse +import io.reactivex.Observable + +interface IWriteOffRepository { + + fun queryWriteoffCount(context: Context, taskId: Long, siteId: Long): Observable? + + fun writeOffEvent(writeOffDetialMsg: WriteOffDetialMsg): Observable? + + fun release() + + fun canCanEndTask(taskId: Long): Boolean { + return true + } + + fun queryWaitUploadData(): Observable>? + fun writeOffEvent4Socket(passenger: WriteOffPassenger) { + + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/impl/WriteOffCacheRepository.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/impl/WriteOffCacheRepository.kt new file mode 100644 index 0000000000..108c27b69a --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/impl/WriteOffCacheRepository.kt @@ -0,0 +1,291 @@ +package com.mogo.och.unmanned.repository.writeoff.impl + +import android.content.Context +import com.mogo.commons.env.Project +import com.mogo.commons.env.ProjectUtils +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.Product +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.common.module.manager.cache.OchSPManager +import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.bean.WaitUploadLine +import com.mogo.och.unmanned.bean.WaitUploadTask +import com.mogo.och.unmanned.bean.WriteOffPassenger +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.repository.db.bean.WriteOffDataBean +import com.mogo.och.unmanned.repository.db.repository.EventDb +import com.mogo.och.unmanned.repository.db.repository.WriteOffDb +import com.mogo.och.unmanned.repository.exception.DataException +import com.mogo.och.unmanned.repository.net.exception.NetException +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse +import com.mogo.och.unmanned.repository.net.project.saas.bus.SaasBusServiceManager +import com.mogo.och.unmanned.repository.net.project.saas.scheduled.SaasScheduledServiceManager +import com.mogo.och.unmanned.repository.writeoff.IWriteOffRepository +import io.reactivex.Observable +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.schedulers.Schedulers + +class WriteOffCacheRepository : IWriteOffRepository { + private val TAG = "${M_BUS}ShuttleSaasRepository" + + private var weakNetInterface: NetInterface?=null + get() { + if(field==null){ + when (ProjectUtils.getProjectType()) { + Project.SAAS -> { + if(AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = SaasScheduledServiceManager + }else if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = SaasBusServiceManager + } + } + Project.DALI -> { +// throw NetException("缓存weakNetInterface 初始化环境错误 Dali") + throw NetException(StringUtils.getString(R.string.module_och_cache_init_env_error_dali)) + } + Project.MOGO -> { +// throw NetException("缓存weakNetInterface 初始化环境错误 MOGO") + throw NetException(StringUtils.getString(R.string.module_och_cache_init_env_error_mogo)) + } + else->{ +// throw NetException("缓存weakNetInterface 初始化环境错误 未知") + throw NetException(StringUtils.getString(R.string.module_och_cache_init_env_error_unknown)) + } + } + } + return field + } + + + override fun queryWriteoffCount( + context: Context, + taskId: Long, + siteId: Long + ): Observable? { + val queryWriteOffByTaskAndSiteId = WriteOffDb.queryWriteOffByTaskAndSiteId(taskId, siteId) + queryWriteOffByTaskAndSiteId?.let { + var count4Persion = 0 + it.forEach { wirteoffItem-> + if (wirteoffItem.ticketSize == null || wirteoffItem.ticketSize!! < 1) { + wirteoffItem.ticketSize=1 + } + count4Persion+=(wirteoffItem.ticketSize?:1) + } + return Observable.just(count4Persion) + .flatMap { + return@flatMap Observable.just(it) + } + } + return Observable.just(0) + } + + override fun writeOffEvent(writeOffDetialMsg: WriteOffDetialMsg): Observable? { + + return Observable.just(writeOffDetialMsg) + .flatMap { + // 1、校验数据 + /** + * 0、校验 tenantId + * 1、校验pipe 校验project + * 2、校验业务模式 bus和接驳 + * 3、校验二维码有效性(向后1分钟有效) + * 4、校验乘车日期 + * 5、校验线路 + * + * 接驳 + * 6、校验次数 + * 7、同一个订单2分钟内只能执行一次 + * 小巴 + * 6、校验站点 + */ + var lineId:Long?=null + var siteId:Long?=null + + + // 1、校验租户id + it.tenantId?.let { tenantId-> + if(LoginStatusManager.getOchCarInfo()?.tenantId==tenantId){ + + }else{ +// throw DataException(1012,"当前用户下单路线非当前的车辆所属公司") + throw DataException(1012, StringUtils.getString(R.string.module_och_current_user_order_not_current_company)) + } + } + // 2、校验project + if(ProjectUtils.isSaas()){ + if(it.pipe != WriteOffDataBean.saasXiaoChengXu){ +// throw DataException(1012,"当前用户下单路线非当前的车辆所属公司") + throw DataException(1012, StringUtils.getString(R.string.module_och_current_user_order_not_current_company)) + } + }else if(ProjectUtils.isDali()){ + if(it.pipe != WriteOffDataBean.daliXiaoChengXu){ +// throw DataException(1012,"当前用户下单路线非当前的车辆所属公司") + throw DataException(1012, StringUtils.getString(R.string.module_och_current_user_order_not_current_company)) + } + } + // 3、校验 bus和shuttle + if (LoginStatusManager.getProductType()!=Product.valueOf(it.typeBiz)) { +// throw DataException(1005,"车辆未登录、或没有任务") + throw DataException(1005, StringUtils.getString(R.string.module_och_not_login_car)) + } + // 4 二维码1分钟失效 + if(System.currentTimeMillis()-(it.expiryTime?:0L)>60_000){ +// throw DataException(6001,"二维码已过期") + throw DataException(6001, StringUtils.getString(R.string.module_och_qr_code_expires)) + } + // 5 校验乘车日期 + if(!DateTimeUtil.isSameDay(System.currentTimeMillis(),it.bookingTime?:0)){ +// throw DataException(1009,"车票所选乘车日期非今日") + throw DataException(1009, StringUtils.getString(R.string.module_och_ticket_not_today)) + } + // 6、校验线路 + if(LineManager.lineInfos==null||LineManager.lineInfos?.lineId==null){ +// throw DataException(1005,"车辆未登录、或没有任务") + throw DataException(1005, StringUtils.getString(R.string.module_och_not_login_car)) + } + if(it.lineId==LineManager.lineInfos?.lineId){ + lineId = it.lineId + }else{ +// throw DataException(1006,"车票路线信息与当前车辆执行任务的路线信息不符合") + throw DataException(1006, StringUtils.getString(R.string.module_och_ticket_line_current_car_line_inconformity)) + } + if (!it.orderNo.isNullOrEmpty()) { + val lastWriteOff = WriteOffDb.queryWaitUpdateEventCount(it.orderNo!!) + // 7、校验次数 + if ((it.availableTimes ?: 0) <= (lastWriteOff?.size ?: 0)) { +// throw DataException(1008, "车票剩余可用次数为0") + throw DataException(1008, StringUtils.getString(R.string.module_och_ticket_not_used)) + } + if (AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + // 8、同一个订单2分钟内只能核销一次 + if (lastWriteOff != null && lastWriteOff.size > 0) { + if (System.currentTimeMillis() - lastWriteOff.last().eventSaveTime <= 120_000) { +// throw DataException(6002, "同一订单核销间隔时间需大于2分钟") + throw DataException(6002, StringUtils.getString(R.string.module_och_interval_canceling_same_order_too_short)) + } + } + + val (start, _) = LineManager.getStations() + siteId = start?.siteId?.toLong() ?: 0 + } else if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + // 8、校验起始站点 + val (start, _) = LineManager.getStations() + if (start?.siteId?.toLong() == it.startStationId) { + siteId = it.startStationId + } else { +// throw DataException(6003, "车票站点信息与当前车辆执行任务的站点信息不符合") + throw DataException(6003, StringUtils.getString(R.string.module_och_ticket_station_current_car_station_inconformity)) + } + } else if(AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)){ + val (start, _) = LineManager.getStations() + siteId = start?.siteId?.toLong() ?: 0 + // 8、校验起始站点 + val task = LineModel.currentTask + if(task==null){ +// throw DataException(6004, "车辆未执行任务") + throw DataException(6004, StringUtils.getString(R.string.module_och_vehicle_not_duty)) + }else{ + if (task.taskId!=it.shiftsId) { +// throw DataException(6005, "车票站点信息与当前车辆执行任务信息不符合") + throw DataException(6005, StringUtils.getString(R.string.module_och_ticket_station_current_car_task_inconformity)) + } + } + } + } else { +// throw DataException(11000, "缺少orderNo") + throw DataException(11000, StringUtils.getString(R.string.module_och_not_order_no)) + } + + val addWrite = WriteOffDataBean() + addWrite.expiryTime = it.expiryTime + addWrite.bookingTime = it.bookingTime + addWrite.type = it.type + addWrite.shiftsId = it.shiftsId + addWrite.taskId = LineModel.currentTask?.taskId + addWrite.taskDate = LineModel.currentTask?.taskDate + addWrite.lineId = lineId + addWrite.siteId = siteId + addWrite.availableTimes = it.availableTimes + addWrite.orderNo = it.orderNo + addWrite.uid = it.uid + addWrite.phone = it.phone + addWrite.ticketSize = it.ticketSize + addWrite.ticketName = it.ticketName + addWrite.msgId = OchSPManager.getSn()+System.currentTimeMillis() + addWrite.driverId = LoginStatusManager.getOchLoginInfo()?.driverId?:0 + addWrite.businessTime = System.currentTimeMillis() + WriteOffDb.addOrUpdate(addWrite) + val reslut = PassengerWriteOffResponse.Result(it.phone,it.ticketSize,it.ticketName,it.availableTimes?.toLong(),addWrite.businessTime) + return@flatMap Observable.just(reslut) + } + } + + override fun canCanEndTask(taskId: Long): Boolean { + val queryWaitUpdateEventByTaskId = WriteOffDb.queryWaitUpdateEventByTaskId(taskId) + return queryWaitUpdateEventByTaskId.isNullOrEmpty() + } + + override fun queryWaitUploadData(): Observable>? { + return EventDb.queryWaitUploadData() + ?.flatMap { waitUploadList-> + val result = mutableListOf() + waitUploadList.forEach { wait-> + if(wait.lineId!=null&&wait.lineName!=null&&wait.taskId!=null&&wait.taskStartTime!=null) { + val waitUpdateEventCount = WriteOffDb.queryWaitUpdateEventCountByTaskId(wait.taskId!!) + val tempTask = WaitUploadTask(wait.taskStartTime!!,wait.taskId!!,waitUpdateEventCount) + val tempLine = WaitUploadLine(wait.lineName!!, wait.lineId!!, mutableListOf(tempTask)) + val haveSave = result.filter { + it.lineId==tempLine.lineId + } + if(haveSave.isEmpty()){ + result.add(tempLine) + }else{ + haveSave.first().task.add(tempTask) + } + } + } + Observable.just(result) } + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + } + + /** + * 小程序核销的乘客插入到计算核销人数的包中 + */ + override fun writeOffEvent4Socket(passenger: WriteOffPassenger) { + val addWrite = WriteOffDataBean() + //addWrite.expiryTime = it.expiryTime + //addWrite.bookingTime = it.bookingTime + //addWrite.type = it.type + addWrite.taskId = LineModel.currentTask?.taskId + addWrite.shiftsId = LineModel.currentTask?.shiftsId + LineManager.getStationsWithLine { start, end, lineInfo -> + addWrite.siteId = start.siteId.toLong() + addWrite.lineId = lineInfo.lineId + } + //addWrite.availableTimes = it.availableTimes + addWrite.orderNo = passenger.orderNo + //addWrite.uid = it.uid + addWrite.phone = passenger.phone + addWrite.ticketSize = passenger.passengerSize + addWrite.ticketName = passenger.ticketName + //addWrite.msgId = OchSPManager.getSn()+System.currentTimeMillis() + addWrite.driverId = LoginStatusManager.getOchLoginInfo()?.driverId?:0 + //addWrite.businessTime = System.currentTimeMillis() + addWrite.updateStatus = WriteOffDataBean.updated + WriteOffDb.addOrUpdate(addWrite) + } + + override fun release() { + weakNetInterface = null + CallerLogger.d(TAG,"重置 weakNetInterface") + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/impl/WriteOffNormallRepository.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/impl/WriteOffNormallRepository.kt new file mode 100644 index 0000000000..f33b51373d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/repository/writeoff/impl/WriteOffNormallRepository.kt @@ -0,0 +1,113 @@ +package com.mogo.och.unmanned.repository.writeoff.impl + +import android.content.Context +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.env.Project +import com.mogo.commons.env.ProjectUtils +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.common.module.manager.socket.lan.bean.WriteOffDetialMsg +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.bean.WaitUploadLine +import com.mogo.och.unmanned.bean.WaitUploadTask +import com.mogo.och.unmanned.bean.response.WriteOffCountResponse +import com.mogo.och.unmanned.repository.db.repository.EventDb +import com.mogo.och.unmanned.repository.net.NetInterface +import com.mogo.och.unmanned.repository.net.bean.request.PassengerWriteOffRequest +import com.mogo.och.unmanned.repository.net.bean.response.PassengerWriteOffResponse +import com.mogo.och.unmanned.repository.net.exception.NetException +import com.mogo.och.unmanned.repository.net.project.dali.bus.DaliBusServiceManager +import com.mogo.och.unmanned.repository.net.project.dali.shuttle.DaliShuttleServiceManager +import com.mogo.och.unmanned.repository.writeoff.IWriteOffRepository +import io.reactivex.Observable +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.schedulers.Schedulers + +class WriteOffNormallRepository: IWriteOffRepository { + + private val TAG = "${M_BUS}WriteOffNormallRepository" + + private var normalNetInterface: NetInterface?=null + get() { + if(field==null){ + when (ProjectUtils.getProjectType()) { + Project.SAAS -> { +// throw NetException("writeoff 核销 初始化环境错误 SAAS") + throw NetException(StringUtils.getString(R.string.module_och_verification_init_env_error_saas)) + } + Project.DALI -> { + if(AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)) { + field = DaliShuttleServiceManager + }else if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + field = DaliBusServiceManager + } + } + Project.MOGO -> { +// throw NetException("writeoff 核销 初始化环境错误 MOGO") + throw NetException(StringUtils.getString(R.string.module_och_verification_init_env_error_mogo)) + } + else->{ +// throw NetException("writeoff 核销 初始化环境错误 未知") + throw NetException(StringUtils.getString(R.string.module_och_verification_init_env_error_unknown)) + } + } + } + return field + } + + init { + + } + + + override fun queryWriteoffCount( + context: Context, + taskId: Long, + siteId: Long, + ): Observable? { + return normalNetInterface?.writeOffCount(context,taskId,siteId) + } + + + override fun writeOffEvent(writeOffDetialMsg: WriteOffDetialMsg): Observable? { + val passengerWriteOffRequest = PassengerWriteOffRequest(writeOffDetialMsg.orderNo, writeOffDetialMsg.uid) + return normalNetInterface?.writeOffTicket( + AbsMogoApplication.getApp(), + passengerWriteOffRequest, + ) + } + + override fun release() { + normalNetInterface=null + CallerLogger.d(TAG,"重置 normalNetInterface") + } + + override fun queryWaitUploadData(): Observable>? { + return EventDb.queryWaitUploadData() + ?.flatMap { waitUploadList-> + val result = mutableListOf() + waitUploadList.forEach { wait-> + if(wait.lineId!=null&&wait.lineName!=null&&wait.taskId!=null&&wait.taskStartTime!=null) { + val tempTask = WaitUploadTask(wait.taskStartTime!!,wait.taskId!!,0) + val tempLine = WaitUploadLine(wait.lineName!!, wait.lineId!!, mutableListOf(tempTask)) + val haveSave = result.filter { + it.lineId==tempLine.lineId + } + if(haveSave.isEmpty()){ + result.add(tempLine) + }else{ + haveSave.first().task.add(tempTask) + } + } + } + Observable.just(result) } + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/bizswitch/SwitchBizView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/bizswitch/SwitchBizView.kt new file mode 100644 index 0000000000..053af9336a --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/bizswitch/SwitchBizView.kt @@ -0,0 +1,146 @@ +package com.mogo.och.unmanned.ui.bizswitch + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import io.reactivex.disposables.Disposable +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_biz.view.unmannedSwitchLine +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_biz.view.unmannedSwitchTask +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_biz.view.unmannedTaskRunning +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_biz.view.unmanned_loading_biz + +class SwitchBizView : ConstraintLayout, SwtichBizModel.SwtichLineViewCallback { + + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes) + + + companion object { + const val TAG = M_BUS + "SwitchBizView" + } + + private var viewModel: SwtichBizModel? = null + + private var queryTimeout: Disposable? = null + + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_switch_biz, this, true) + initView() + } + + private fun initView() { + unmanned_loading_biz.setEmptyText(ResourcesUtils.getString(R.string.unmanned_bus_switch_biz_loading)) + } + + override fun onAttachedToWindow() { + CallerLogger.d(TAG, "SwitchBizView:onAttachedToWindow") + super.onAttachedToWindow() + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it)[SwtichBizModel::class.java] + } + viewModel?.setSwitchBizCallback(this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerLogger.d(TAG, "SwitchBizView:onDetachedFromWindow") + } + + var startLoading = System.currentTimeMillis() + + /** + * 展示loading页面 + * 1、 + * 2、第一次加载页面时展示 + * 3、 + */ + override fun showLoadingView() { + startLoading = System.currentTimeMillis() + CallerLogger.d(TAG, "开始展示 lading 时间:${startLoading}") + unmanned_loading_biz.visibility = VISIBLE + unmannedSwitchLine.visibility = GONE + unmannedSwitchTask.visibility = GONE + queryTimeout = RxUtils.createSubscribe(10_000) { + OchChainLogManager.writeChainLog("Loading超时", "loading 展示了10s") + CallerLogger.d(TAG, "Loading超时:loading 展示了10s") + viewModel?.queryRuningTask() + } + } + + /** + * 初始化数据 + */ + override fun loadLineData() { + unmannedSwitchLine.loadingDatas() + } + + override fun showSwitchTaskByLineInfo(lineInfo: LineDataBean) { + // 展示loading + showLoadingView() + unmannedSwitchTask.queryTaskByLineInfo(lineInfo) + } + + // 展示选择任务页面 + override fun showSwitchTaskInfo() { + RxUtils.disposeSubscribe(queryTimeout) + val endLoading = System.currentTimeMillis() + val dex = (100 - (endLoading - startLoading)).takeIf { it >= 0 } ?: 0 + CallerLogger.d(TAG, "展示任务 lading 展示了 ${dex}毫秒") + + ThreadUtils.runOnUiThreadDelayed({ + unmanned_loading_biz.visibility = GONE + unmannedSwitchLine.visibility = GONE + unmannedSwitchTask.visibility = VISIBLE + unmannedTaskRunning.visibility = GONE + }, dex, ThreadUtils.MODE.QUEUE) + } + + // 展示选择线路页面 + override fun showSwtichLineView() { + RxUtils.disposeSubscribe(queryTimeout) + val endLoading = System.currentTimeMillis() + val dex = (100 - (endLoading - startLoading)).takeIf { it >= 0 } ?: 0 + CallerLogger.d(TAG, "展示线路 lading 展示了 ${dex}毫秒") + ThreadUtils.runOnUiThreadDelayed({ + unmanned_loading_biz.visibility = GONE + unmannedSwitchLine.visibility = VISIBLE + unmannedSwitchTask.visibility = GONE + unmannedTaskRunning.visibility = GONE + }, dex, ThreadUtils.MODE.QUEUE) + + } + + // 展示正在进行的任务 + override fun loadRunningTask() { + RxUtils.disposeSubscribe(queryTimeout) + val endLoading = System.currentTimeMillis() + val dex = (100 - (endLoading - startLoading)).takeIf { it >= 0 } ?: 0 + CallerLogger.d(TAG, "展示运行中任务 lading 展示了 ${dex}毫秒") + ThreadUtils.runOnUiThreadDelayed({ + unmanned_loading_biz.visibility = GONE + unmannedSwitchLine.visibility = GONE + unmannedSwitchTask.visibility = GONE + unmannedTaskRunning.visibility = VISIBLE + unmannedTaskRunning.showRunningTaskInfo() + }, dex, ThreadUtils.MODE.QUEUE) + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/bizswitch/SwtichBizModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/bizswitch/SwtichBizModel.kt new file mode 100644 index 0000000000..89d1e62584 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/bizswitch/SwtichBizModel.kt @@ -0,0 +1,92 @@ +package com.mogo.och.unmanned.ui.bizswitch + +import androidx.lifecycle.ViewModel +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.och.unmanned.callback.IBusLinesCallback +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.model.OrderModel +import com.mogo.och.unmanned.repository.db.bean.LineDataBean + +/** + * @author XuXinChao + * @description BadCase录包管理页面 + * @since: 2022/12/15 + */ +class SwtichBizModel : ViewModel(), IBusLinesCallback { + + private val TAG = M_BUS + SwtichBizModel::class.java.simpleName + + private var viewCallback: SwtichLineViewCallback? = null + + + override fun onCleared() { + d(TAG, "onCleared") + LineModel.setBusLinesCallback(TAG, null) + } + + fun setSwitchBizCallback(viewCallback: SwtichLineViewCallback) { + d(TAG, "setSwitchBizCallback") + LineModel.setBusLinesCallback(TAG, this) + this.viewCallback = viewCallback + this.viewCallback?.showLoadingView() + ThreadUtils.getIoPool().execute { + OrderModel.queryBusRoutes() + } + } + + fun queryRuningTask() { + ThreadUtils.getIoPool().execute { + OrderModel.queryBusRoutes() + } + } + + fun loadingSwitchTask(lineInfo: LineDataBean) { + d(TAG, "loadingSwitchTask 查询线路的任务线路信息:${lineInfo}") + viewCallback?.showSwitchTaskByLineInfo(lineInfo) + } + + fun showSwitchTaskInfo() { + viewCallback?.showSwitchTaskInfo() + } + + fun showSwitchLineInfo() { + viewCallback?.showLoadingView() + viewCallback?.loadLineData() + } + + fun showSwitchLineInfoResult() { + viewCallback?.showSwtichLineView() + } + + fun showRunningTaskView() { + + } + + interface SwtichLineViewCallback { + fun showSwtichLineView() + fun showLoadingView() + fun showSwitchTaskByLineInfo(lineInfo: LineDataBean) + fun showSwitchTaskInfo() + fun loadLineData() + fun loadRunningTask() + } + + + override fun onNoRunningTask() { + this.viewCallback?.loadLineData() + d(TAG, "没有任务去加载线路") + } + + override fun onRunningTask() { + this.viewCallback?.loadRunningTask() + d(TAG, "有任务去加载正在执行的任务") + } + + + override fun onCompleteTask() { + OrderModel.queryBusRoutes() + } +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/fragment/BusPresenter.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/fragment/BusPresenter.kt new file mode 100644 index 0000000000..30e5575a37 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/fragment/BusPresenter.kt @@ -0,0 +1,57 @@ +package com.mogo.och.unmanned.ui.fragment + +import androidx.lifecycle.LifecycleOwner +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.mvp.Presenter +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.bridge.autopilot.OCHAdasAbilityManager +import com.mogo.och.common.module.biz.login.EnumLoginStatus +import com.mogo.och.common.module.biz.login.ILoginCallback +import com.mogo.och.common.module.biz.login.LoginStatusManager +import com.mogo.och.common.module.biz.login.LoginStatusManager.isLogin +import com.mogo.och.unmanned.model.OrderModel +import com.mogo.och.unmanned.util.BusTrajectoryManager + +/** + * 网约车小巴 + * + * @author tongchenfei + */ +class BusPresenter(view: ShuttleFragment?) : Presenter(view), ILoginCallback { + + override fun onCreate(owner: LifecycleOwner) { + super.onCreate(owner) + initModelListener() + } + + override fun onDestroy(owner: LifecycleOwner) { + super.onDestroy(owner) + + releaseListener() + } + + private fun initModelListener() { + OCHAdasAbilityManager.getInstance().init(AbsMogoApplication.getApp()) + LoginStatusManager.addListener(TAG, this) + OrderModel.init() + } + + private fun releaseListener() { + OCHAdasAbilityManager.getInstance().release() + LoginStatusManager.removeListener(TAG) + OrderModel.release() + } + + override fun onLoginStatusChange(currentStatus: EnumLoginStatus) { + d(TAG, " loginStatus =" + isLogin()) + if (!isLogin()) { + BusTrajectoryManager.stopTrajReqLoop() + OrderModel.closeBeautificationMode() + } + } + + companion object { + private const val TAG = M_BUS + "BusPresenter" + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/fragment/ShuttleFragment.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/fragment/ShuttleFragment.kt new file mode 100644 index 0000000000..303df2823f --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/fragment/ShuttleFragment.kt @@ -0,0 +1,83 @@ +package com.mogo.och.unmanned.ui.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.mogo.commons.mvp.MvpFragment +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.shuttle.unmanned.R + +/** + * 网约车基础Fragment,主要负责布局通用界面,处理站点面板和通话面板互斥情况 + * + * + * 部分业务放在了此处处理 + * + * @author tongchenfei + */ +class ShuttleFragment : MvpFragment() { + + + override fun getLayoutId(): Int { + return R.layout.shuttle_unmanned_base_fragment + } + + override fun getTagName(): String { + return "ShuttleFragment" + } + + override fun initViews() { + + + } + + override fun initViews(savedInstanceState: Bundle?) { + super.initViews(savedInstanceState) + } + + override fun createPresenter(): BusPresenter { + return BusPresenter(this) + } + + override fun onResume() { + super.onResume() + } + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return super.onCreateView(inflater, container, savedInstanceState) + } + + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + } + + override fun onLowMemory() { + super.onLowMemory() + } + + override fun onPause() { + super.onPause() + } + + override fun onDestroyView() { + if (mPresenter != null) { + mPresenter!!.onDestroy(this) + } + super.onDestroyView() + } + + override fun onDestroy() { + super.onDestroy() + } + + /** + * END + */ + companion object { + private const val TAG = "${M_BUS}BaseBusTabFragment" + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/TopSwitchBizView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/TopSwitchBizView.kt new file mode 100644 index 0000000000..dc76ee0753 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/modeswitch/TopSwitchBizView.kt @@ -0,0 +1,40 @@ +package com.mogo.och.unmanned.ui.modeswitch + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import com.mogo.och.common.module.wigets.WindowRelativeLayout +import com.mogo.och.shuttle.unmanned.R + +class TopSwitchBizView : WindowRelativeLayout { + + + constructor(context: Context?) : super(context) + + constructor(context: Context?, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context?, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) + + constructor(context: Context?, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes) + + + companion object { + const val TAG = "TopSwitchBizView" + } + + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_biz, this, true) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + } + + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/qr/QrOpenView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/qr/QrOpenView.kt new file mode 100644 index 0000000000..f8ecd2be48 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/qr/QrOpenView.kt @@ -0,0 +1,80 @@ +package com.mogo.och.unmanned.ui.qr + +import android.content.Context +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatImageView +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.ActivityUtils +import com.mogo.eagle.core.utilcode.util.ImageUtils +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.utils.createQRCodeWithPicture +import com.mogo.och.common.module.wigets.BindQRCodeDialog +import com.mogo.och.shuttle.unmanned.R +import com.mogo.skin.utils.SkinResources +import me.jessyan.autosize.utils.AutoSizeUtils + +class QrOpenView : AppCompatImageView { + + private val TAG = M_BUS + "QrOpenView" + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super( + context, + attributeSet, + defStyleAttr + ) + + private fun initView() { + setImageResource(R.drawable.unmanned_bus_open_qr) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + + onClick { + d( + TAG, "changeOverview Event qrcode,sn = " + + SharedPrefsMgr.getInstance().sn + ) + val qrUrl = String.format( + FunctionBuildConfig.urlJson.bindDriverQRUrl, + SharedPrefsMgr.getInstance().sn + ) + val qrCenterLogoDrawable = + SkinResources.getInstance().getDrawable(R.drawable.icon_qr_center_logo) + val qrCenterLogoBitmap = ImageUtils.drawable2Bitmap(qrCenterLogoDrawable) + + val bmQr = createQRCodeWithPicture( + qrCenterLogoBitmap, + qrUrl, AutoSizeUtils.dp2px(context, 340f), + AutoSizeUtils.dp2px(context, 340f), true + ) + if (bmQr != null) { + val builder = BindQRCodeDialog.Builder() + builder.title(ResourcesUtils.getString(R.string.bind_driver_qr_title)) + .cancelStr(ResourcesUtils.getString(R.string.qr_cancel)) + .qrBm(bmQr).build(ActivityUtils.getTopActivity())!!.show() + } else { + d(TAG, "bmQr = null ") + } + } + } + + + init { + try { + initView() + } catch (e: Exception) { + e.printStackTrace() + } + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwitchLineAdapter.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwitchLineAdapter.kt new file mode 100644 index 0000000000..c3a15d6ed0 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwitchLineAdapter.kt @@ -0,0 +1,105 @@ +package com.mogo.och.unmanned.ui.switchline + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.widget.AppCompatTextView +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.DiffUtil.Callback +import androidx.recyclerview.widget.RecyclerView +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.ui.switchline.SwitchLineAdapter.SwitchLineViewHolder +import me.jessyan.autosize.AutoSizeCompat + +/** + * 路线列表adapter + */ +class SwitchLineAdapter( + private val mContext: Context, + val mData: MutableList +) : RecyclerView.Adapter() { + companion object { + const val TAG = M_BUS + "SwitchLineAdapter" + } + + // RecyclerView设置点击事件 + private var mItemClickListener: LineItemClickListener? = null + + fun setDataList(dataList: List) { + + val diffResult = DiffUtil.calculateDiff(MyDiffCallback(this.mData, dataList)) + this.mData.clear() + this.mData.addAll(dataList) + diffResult.dispatchUpdatesTo(this) + } + + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int + ): SwitchLineViewHolder { + val view = LayoutInflater.from(mContext).inflate( + R.layout.shuttle_unmanned_switch_line_list_item, parent, false + ) + return SwitchLineViewHolder(view) + } + + override fun onBindViewHolder(holder: SwitchLineViewHolder, position: Int) { + val currentPosition = holder.bindingAdapterPosition + AutoSizeCompat.autoConvertDensityOfGlobal(holder.itemView.resources) + val line = mData[currentPosition] + + holder.lineName.text = line.lineName + val string = mContext.getString(R.string.unmanned_bus_line_goto_end, line.endStationName) + holder.lineEndName.text = string + + + //设置item点击事件 + holder.itemView.setOnClickListener { + mItemClickListener?.onItemClick(line) + } + } + + override fun getItemCount(): Int { + return mData.size + } + + fun setOnLineItemClickListener(itemClickListener: LineItemClickListener?) { + mItemClickListener = itemClickListener + } + + class SwitchLineViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val lineName: AppCompatTextView = itemView.findViewById(R.id.unmanned_switch_line_name)//线路名称 + val lineEndName: AppCompatTextView = itemView.findViewById(R.id.unmanned_switch_line_end_station) //终点 + } + + interface LineItemClickListener { + fun onItemClick(data: LineDataBean) + } + + inner class MyDiffCallback(private val oldData: List, private val newData: List) : + Callback() { + override fun getOldListSize(): Int { + return oldData.size + } + + override fun getNewListSize(): Int { + return newData.size + } + + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldData[oldItemPosition] + val newItem = newData[newItemPosition] + return oldItem == newItem && oldItem.endStationName == newItem.endStationName + } + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldData[oldItemPosition] + val newItem = newData[newItemPosition] + return oldItem == newItem && oldItem.endStationName == newItem.endStationName + } + + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwitchLineView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwitchLineView.kt new file mode 100644 index 0000000000..f555cd3bd2 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwitchLineView.kt @@ -0,0 +1,191 @@ +package com.mogo.och.unmanned.ui.switchline + +import android.animation.ObjectAnimator +import android.animation.ValueAnimator +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.mogo.view.SpacesItemDecoration +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.wigets.WindowRelativeLayout +import com.mogo.och.common.module.wigets.WrapContentLinearLayoutManager +import com.mogo.och.common.module.wigets.commonview.ErrorView +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.ui.bizswitch.SwtichBizModel +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_line.view.unmanned_aciv_refresh_task +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_line.view.unmanned_actv_last_refresh_date +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_line.view.unmanned_include_empty +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_line.view.unmanned_include_errorview +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_line.view.unmanned_switch_line_rv +import me.jessyan.autosize.utils.AutoSizeUtils + + +class SwitchLineView : WindowRelativeLayout, SwtichLineModel.SwtichLineViewCallback { + + + constructor(context: Context?) : super(context) + + constructor(context: Context?, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context?, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) + + constructor(context: Context?, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes) + + + companion object { + const val TAG = "${M_BUS}SwitchLineView" + } + + private var viewModel: SwtichLineModel? = null + private var viewbizModel: SwtichBizModel? = null + + private lateinit var mAdapter: SwitchLineAdapter + + private var animator: ObjectAnimator? = null + + + private lateinit var linearLayoutManager: WrapContentLinearLayoutManager + + private var animatorStart = System.currentTimeMillis() + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_switch_line, this, true) + initView() + } + + private fun initView() { + linearLayoutManager = WrapContentLinearLayoutManager(context) + unmanned_switch_line_rv.setLayoutManager(linearLayoutManager) + mAdapter = SwitchLineAdapter(context, mutableListOf()) + unmanned_switch_line_rv.addItemDecoration( + SpacesItemDecoration( + AutoSizeUtils.dp2px(context, 20f) + ) + ) + unmanned_switch_line_rv.setAdapter(mAdapter) + //设置item 点击事件 + mAdapter.setOnLineItemClickListener(object : SwitchLineAdapter.LineItemClickListener { + override fun onItemClick(data: LineDataBean) { + CallerLogger.d(TAG, "选择线路 线路信息:${data}") + viewbizModel?.loadingSwitchTask(data) + } + }) + + unmanned_aciv_refresh_task.onClick(5_000) { + if (RepositoryManager.supportDb()) { + viewModel?.refreshTask() + } else { + loadingDatas() + } + animatorStart = System.currentTimeMillis() + if (animator == null) { + animator = ObjectAnimator.ofFloat(unmanned_aciv_refresh_task, "rotation", 0f, 360f) + animator?.setDuration(1000) // 设置动画持续时间 + animator?.repeatCount = ValueAnimator.INFINITE // 设置动画无限重复 + animator?.repeatMode = ValueAnimator.RESTART // 设置重复模式 + } + animator?.start() + } + unmanned_include_errorview.reloadLIstener = object : ErrorView.ReloadLIstener { + override fun reload() { + viewbizModel?.showSwitchLineInfo() + } + + } + } + + /** + * 初始化数据 + */ + fun loadingDatas() { + CallerLogger.d(TAG, "加载线路去") + viewModel?.queryBusLines(true) + viewModel?.setRefreshTime() + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(SwtichLineModel::class.java) + } + viewbizModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(SwtichBizModel::class.java) + } + + viewModel?.setDistanceCallback(this) + CallerLogger.d(TAG, "onAttachedToWindow") + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerLogger.d(TAG, "onDetachedFromWindow") + } + + override fun startTaskState(success: Boolean) { + + } + + override fun onBusLinesChange(data: MutableList?, show: Boolean) { + if (data.isNullOrEmpty()) { + showNoData(true) + } else { + showNoData(false) + mAdapter.setDataList(data) + } + CallerLogger.d(TAG, "加载线路成功") + if (show) { + viewbizModel?.showSwitchLineInfoResult() + } + } + + /** + * 有无数据UI显示 + * @param b + */ + private fun showNoData(b: Boolean) { + BizLoopManager.runInMainThread { + unmanned_include_errorview.visibility = View.GONE + if (b) { + unmanned_switch_line_rv.visibility = View.GONE + unmanned_include_empty.visibility = View.VISIBLE + } else { + unmanned_switch_line_rv.visibility = View.VISIBLE + unmanned_include_empty.visibility = View.GONE + } + } + } + + override fun refreshDate(formatLongToString: String?) { + val endTime = System.currentTimeMillis() + val dex = (1000 - (endTime - animatorStart)).takeIf { it >= 0 } ?: 0 + UiThreadHandler.postDelayed( + { + formatLongToString?.let { + unmanned_actv_last_refresh_date.text = ResourcesUtils.getString(R.string.unmanned_bus_refresh_time, it) + animator?.cancel() + } + }, + dex, UiThreadHandler.MODE.QUEUE, + ) + + } + + override fun onBusLinesChangeFaile() { + unmanned_include_errorview.visibility = View.VISIBLE + unmanned_switch_line_rv.visibility = View.GONE + unmanned_include_empty.visibility = View.GONE + viewbizModel?.showSwitchLineInfoResult() + } + + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwtichLineModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwtichLineModel.kt new file mode 100644 index 0000000000..a9ff4d0be4 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchline/SwtichLineModel.kt @@ -0,0 +1,112 @@ +package com.mogo.och.unmanned.ui.switchline + +import androidx.lifecycle.ViewModel +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.unmanned.callback.IBusLinesCallback +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.model.SynchDataModel.EXECUTABLECHANGETIME +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import io.reactivex.Observer +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers + +/** + * @author XuXinChao + * @description BadCase录包管理页面 + * @since: 2022/12/15 + */ +class SwtichLineModel : ViewModel(), IBusLinesCallback { + + private val TAG = M_BUS + SwtichLineModel::class.java.simpleName + + private var viewCallback: SwtichLineViewCallback? = null + + private var endTaskDisposable: Disposable? = null + + + override fun onCleared() { + d(TAG, "onCleared") + LineModel.setBusLinesCallback(TAG, null) + } + + fun setDistanceCallback(viewCallback: SwtichLineViewCallback) { + this.viewCallback = viewCallback + LineModel.setBusLinesCallback(TAG, this) + } + + fun queryBusLines(loading: Boolean) { + RxUtils.disposeSubscribe(endTaskDisposable) + RepositoryManager.queryCanUseLine() + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer?> { + override fun onSubscribe(d: Disposable) { + endTaskDisposable = d + d(TAG, "queryBusLines onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "queryBusLines onError${e.printStackTrace()}") + viewCallback?.onBusLinesChangeFaile() + } + + override fun onComplete() { + d(TAG, "queryBusLines onComplete") + } + + override fun onNext(data: List) { + d(TAG, "queryBusLines onNext ${data}") + val tempData = data.distinctBy { it.lineId } + viewCallback?.onBusLinesChange(tempData.toMutableList(), loading) + if (RepositoryManager.supportDb()) { + + } else { + SharedPrefsMgr.getInstance().putLong(EXECUTABLECHANGETIME, DateTimeUtil.getCurrentTimeStamp()) + onRefreshSuccess(DateTimeUtil.getCurrentTimeStamp()) + } + RxUtils.disposeSubscribe(endTaskDisposable) + } + + }) + } + + fun setRefreshTime() { + val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(EXECUTABLECHANGETIME, -1) + if (lastUpdateTime > 0) { + this.onRefreshSuccess(lastUpdateTime) + } + } + + fun refreshTask() { + LineModel.refreshTask() + } + + interface SwtichLineViewCallback { + fun startTaskState(success: Boolean) + fun onBusLinesChange(data: MutableList?, show: Boolean) + fun refreshDate(formatLongToString: String?) + fun onBusLinesChangeFaile() + } + + override fun onRefreshSuccess(currentTimeStamp: Long) { + viewCallback?.refreshDate( + DateTimeUtil.formatLongToString(currentTimeStamp, DateTimeUtil.HH_mm_ss) + ) + } + + override fun onRefreshSuccessWIthData() { + super.onRefreshSuccessWIthData() + queryBusLines(false) + } + + override fun onChangeLineIdFail() { + viewCallback?.startTaskState(false) + } +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwitchLineTaskAdapter.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwitchLineTaskAdapter.kt new file mode 100644 index 0000000000..71ec7a698f --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwitchLineTaskAdapter.kt @@ -0,0 +1,133 @@ +package com.mogo.och.unmanned.ui.switchtask + +import android.content.Context +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.widget.AppCompatCheckedTextView +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.DiffUtil.Callback +import androidx.recyclerview.widget.RecyclerView +import com.mogo.eagle.core.utilcode.util.TimeUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.och.common.module.biz.order.OrderManager +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.ui.switchtask.SwitchLineTaskAdapter.SwitchLineTaskViewHolder +import me.jessyan.autosize.AutoSizeCompat + +/** + * 路线列表adapter + */ +@Suppress("UNUSED_EXPRESSION") +class SwitchLineTaskAdapter( + private val mContext: Context, + private var checkTask: TaskDataBean?, + private val mData: MutableList, +) : RecyclerView.Adapter() { + + fun setDataList(dataList: List) { + if (this.mData == dataList) { + // 如果新旧列表一致,则直接返回 + return + } + checkTask = null + val diffResult = DiffUtil.calculateDiff(MyDiffCallback(this.mData, dataList)) + this.mData.clear() + this.mData.addAll(dataList) + diffResult.dispatchUpdatesTo(this) + } + + fun getCheckTask(): TaskDataBean? { + return checkTask + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SwitchLineTaskViewHolder { + val view = LayoutInflater.from(mContext).inflate( + R.layout.shuttle_unmanned_switch_task_item, parent, false + ) + return SwitchLineTaskViewHolder(view) + } + + override fun onBindViewHolder(holder: SwitchLineTaskViewHolder, position: Int) { + val currentPosition = holder.bindingAdapterPosition + AutoSizeCompat.autoConvertDensityOfGlobal(holder.itemView.resources) + val task = mData[currentPosition] + val taskStartTime = TimeUtils.millis2String(task.taskStartTime + ?: System.currentTimeMillis(), "HH:mm") + holder.taskTime.text = taskStartTime + + if (checkTask == null) { + holder.taskTime.isChecked = false + } else { + holder.taskTime.isChecked = task == checkTask + } + holder.taskTime.setOnClickListener { + if (!OrderManager.canStartOrder()) { + ToastUtils.showShort(ResourcesUtils.getString(R.string.common_start_task_after_upload_success)) + return@setOnClickListener + } + var preCheckIndex = -1 + if (checkTask == null) { + checkTask = task + } else { + if (checkTask == task) { + checkTask = null + } else { + mData.forEachIndexed { index, result -> + if (checkTask == result) { + checkTask = null + preCheckIndex = index + } + } + checkTask = task + } + } + notifyItemChanged(currentPosition) + if (preCheckIndex >= 0) { + notifyItemChanged(preCheckIndex) + } + } + } + + override fun getItemCount(): Int { + return mData.size + } + + fun setCurrentTaskUsed(taskId: Long) { + mData.forEach { + if (it.taskId == taskId) { + it.status = TaskDataBean.used + } + } + } + + class SwitchLineTaskViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val taskTime: AppCompatCheckedTextView = itemView.findViewById(R.id.unmanned_actv_task_time) // 时间 + } + + inner class MyDiffCallback(private val oldData: List, private val newData: List) : + Callback() { + override fun getOldListSize(): Int { + return oldData.size + } + + override fun getNewListSize(): Int { + return newData.size + } + + override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldData[oldItemPosition] + val newItem = newData[newItemPosition] + return oldItem.taskId == newItem.taskId + } + + override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { + val oldItem = oldData[oldItemPosition] + val newItem = newData[newItemPosition] + return oldItem.taskId == newItem.taskId + } + + } +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwitchTaskView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwitchTaskView.kt new file mode 100644 index 0000000000..267145466e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwitchTaskView.kt @@ -0,0 +1,193 @@ +package com.mogo.och.unmanned.ui.switchtask + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import androidx.recyclerview.widget.GridLayoutManager +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.wigets.TaskBottomDecoration +import com.mogo.och.common.module.wigets.WindowRelativeLayout +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import com.mogo.och.unmanned.ui.bizswitch.SwtichBizModel +import kotlinx.android.synthetic.main.shuttle_unmanned_error_view.view.unmanned_tv_error_msg +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmannedActvLineEndStationName +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmannedBusLineName +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmanned_actv_cancle_task +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmanned_actv_submit_task +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmanned_include_empty +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmanned_include_error +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmanned_loading_start_line +import kotlinx.android.synthetic.main.shuttle_unmanned_switch_task.view.unmanned_rv_switch_task +import me.jessyan.autosize.utils.AutoSizeUtils + + +class SwitchTaskView : WindowRelativeLayout, SwtichTaskModel.SwtichLineViewCallback { + + + constructor(context: Context?) : super(context) + + constructor(context: Context?, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context?, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr) + + constructor(context: Context?, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes) + + + companion object { + const val TAG = M_BUS + "BadCaseManagerView" + } + + private var viewModel: SwtichTaskModel? = null + private var viewbizModel: SwtichBizModel? = null + + private lateinit var mAdapter: SwitchLineTaskAdapter + + private lateinit var linearLayoutManager: GridLayoutManager + + private val tempData = mutableMapOf() + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_switch_task, this, true) + initView() + } + + private fun initView() { + linearLayoutManager = GridLayoutManager(context, 3) + unmanned_rv_switch_task.setLayoutManager(linearLayoutManager) + mAdapter = SwitchLineTaskAdapter(context, null, mutableListOf()) + unmanned_rv_switch_task.setAdapter(mAdapter) + unmanned_rv_switch_task.addItemDecoration( + TaskBottomDecoration(AutoSizeUtils.dp2px(context, 174f), 0) + ) + + unmanned_actv_submit_task.onClick { + val tempCheckTask = mAdapter.getCheckTask() + if (tempCheckTask == null) { +// ToastUtils.showShort("请选择任务") + ToastUtils.showShort(R.string.module_och_please_choose_task) + } else { + if (tempCheckTask.status == TaskDataBean.used) { + val reason = tempData[tempCheckTask.taskId] + if (reason == null) { +// ToastUtils.showShort("该任务已被其他车辆使用、请切换任务") + ToastUtils.showShort(R.string.module_och_this_task_not_use) + } else { +// ToastUtils.showShort("该任务已被${reason}使用、请切换任务") + ToastUtils.showShort(R.string.module_och_this_task_not_use1, reason) + } + } else { + viewModel?.changeLineStart(tempCheckTask) + } + } + } + unmanned_actv_cancle_task.onClick { + mAdapter.setDataList(mutableListOf()) + viewbizModel?.showSwitchLineInfo() + } + unmanned_tv_error_msg.onClick { + viewModel?.tasksBelongLine?.let { + d(TAG, "刷新线路 线路信息:${it}") + viewbizModel?.loadingSwitchTask(it) + } + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(SwtichTaskModel::class.java) + } + viewbizModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(SwtichBizModel::class.java) + } + viewModel?.setDistanceCallback(this) + } + + fun queryTaskByLineInfo(lineInfo: LineDataBean) { + d(TAG, "queryTaskByLineInfo 查询线路的任务线路id:${lineInfo}") + viewModel?.queryBusLineTasksById(lineInfo) + unmannedBusLineName.text = lineInfo.lineName +// unmannedActvLineEndStationName.text = "往${lineInfo.endStationName}方向" + unmannedActvLineEndStationName.text = StringUtils.getString(R.string.unmanned_bus_leave_for, lineInfo.endStationName) + } + + override fun showTaskByLineIdResult(taskList: MutableList?) { + BizLoopManager.runInMainThread { + if (taskList.isNullOrEmpty()) { + showEmptyView() + } else { + showData() + mAdapter.setDataList(taskList) + } + viewbizModel?.showSwitchTaskInfo() + } + } + + private fun showData() { + unmanned_actv_submit_task.setTextColor(ResourcesUtils.getColors(R.color.unmanned_bus_task_submit_text_color_selector)) + unmanned_actv_submit_task.isEnabled = true + unmanned_rv_switch_task.visibility = VISIBLE + unmanned_include_empty.visibility = GONE + unmanned_include_error.visibility = GONE + } + + override fun showLoading() { + unmanned_loading_start_line.visibility = VISIBLE + unmanned_actv_submit_task.isEnabled = false + unmanned_actv_cancle_task.isEnabled = false + } + + override fun hideLoading() { + unmanned_loading_start_line.visibility = GONE + unmanned_actv_submit_task.isEnabled = true + unmanned_actv_cancle_task.isEnabled = true + } + + override fun startTaskSuccess() { + viewbizModel?.showRunningTaskView() + tempData.clear() + } + + override fun showErrorInfo() { +// unmanned_tv_error_msg.text = "发生错误点击重试" + unmanned_tv_error_msg.text = StringUtils.getString(R.string.module_och_error_try_again) + unmanned_actv_submit_task.setTextColor(ResourcesUtils.getColor(R.color.bus_color_66666)) + unmanned_actv_submit_task.isEnabled = false + unmanned_include_error.visibility = VISIBLE + unmanned_rv_switch_task.visibility = GONE + unmanned_include_empty.visibility = GONE + viewbizModel?.showSwitchTaskInfo() + } + + override fun resetRecycleView() { + mAdapter.setDataList(mutableListOf()) + } + + override fun setCurrentTaskUsed(taskId: Long, plateNumber: String) { + BizLoopManager.runInMainThread { + mAdapter.setCurrentTaskUsed(taskId) +// tempData[taskId] = "该任务已被${plateNumber}使用" + tempData[taskId] = StringUtils.getString(R.string.module_och_task_has_been_completed) + } + } + + private fun showEmptyView() { + unmanned_actv_submit_task.setTextColor(ResourcesUtils.getColor(R.color.bus_color_66666)) + unmanned_actv_submit_task.isEnabled = false + unmanned_rv_switch_task.visibility = GONE + unmanned_include_empty.visibility = VISIBLE + unmanned_include_error.visibility = GONE + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwtichTaskModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwtichTaskModel.kt new file mode 100644 index 0000000000..76ccb7ab9c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/switchtask/SwtichTaskModel.kt @@ -0,0 +1,133 @@ +package com.mogo.och.unmanned.ui.switchtask + +import androidx.lifecycle.ViewModel +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.callback.IBusLinesCallback +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.repository.RepositoryManager +import com.mogo.och.unmanned.repository.db.bean.LineDataBean +import com.mogo.och.unmanned.repository.db.bean.TaskDataBean +import io.reactivex.Observer +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable +import io.reactivex.schedulers.Schedulers + +/** + * @author XuXinChao + * @description BadCase录包管理页面 + * @since: 2022/12/15 + */ +class SwtichTaskModel : ViewModel(), IBusLinesCallback { + + private val TAG = M_BUS + SwtichTaskModel::class.java.simpleName + + private var viewCallback: SwtichLineViewCallback? = null + + var tasksBelongLine: LineDataBean? = null + + private var searchTaskBylineIdDisposable: Disposable? = null + + + override fun onCleared() { + LineModel.setBusLinesCallback(TAG, null) + } + + fun setDistanceCallback(viewCallback: SwtichLineViewCallback) { + this.viewCallback = viewCallback + LineModel.setBusLinesCallback(TAG, this) + } + + fun queryBusLineTasksById(lineInfo: LineDataBean) { + tasksBelongLine = lineInfo + RxUtils.disposeSubscribe(searchTaskBylineIdDisposable) + d(TAG, "queryBusLineTasksById 查询线路的任务线路id:${tasksBelongLine}") + RepositoryManager.queryCanUserTask(lineInfo.lineId ?: -1L) + ?.subscribeOn(Schedulers.io()) + ?.observeOn(AndroidSchedulers.mainThread()) + ?.subscribe(object : Observer?> { + override fun onSubscribe(d: Disposable) { + searchTaskBylineIdDisposable = d + d(TAG, "queryBusLineTasksById onSubscribe") + } + + override fun onError(e: Throwable) { + d(TAG, "queryBusLineTasksById onError${e.printStackTrace()}") + onBusLineTasksError() + } + + override fun onComplete() { + d(TAG, "queryBusLineTasksById onComplete") + } + + override fun onNext(data: List) { + d(TAG, "queryBusLineTasksById onNext ${data}") + onBusLineTasks(data.toMutableList()) + RxUtils.disposeSubscribe(searchTaskBylineIdDisposable) + } + }) + } + + interface SwtichLineViewCallback { + fun showTaskByLineIdResult(taskList: MutableList?) + fun showLoading() + fun hideLoading() + fun startTaskSuccess() + fun showErrorInfo() + fun resetRecycleView() + fun setCurrentTaskUsed(taskId: Long, plateNumber: String) + } + + fun onBusLineTasks(o: MutableList?) { + viewCallback?.showTaskByLineIdResult(o) + } + + fun onBusLineTasksError() { + viewCallback?.showErrorInfo() + } + + override fun onRefreshSuccess(currentTimeStamp: Long) { + + } + + // 选择线路成功 + override fun onChangeLineIdSuccess() { + BizLoopManager.runInMainThread { + viewCallback?.hideLoading() + viewCallback?.startTaskSuccess() + viewCallback?.resetRecycleView() + } + } + + // 选择线路失败 + override fun onChangeLineIdFail() { + if (ThreadUtils.isMainThread()) { + viewCallback?.hideLoading() + } else { + ThreadUtils.runOnUiThread({ + viewCallback?.hideLoading() + }, ThreadUtils.MODE.QUEUE) + } + viewCallback?.hideLoading() + } + + fun changeLineStart(checkTask: TaskDataBean) { + if (tasksBelongLine == null) { +// ToastUtils.showShort("请重新选择线路") + ToastUtils.showShort(R.string.module_och_please_choose_line) + return + } + viewCallback?.showLoading() + LineModel.commitSwitchLineId(checkTask, tasksBelongLine!!) + } + + override fun onEndTaskByOther(taskId: Long, plateNumber: String) { + viewCallback?.setCurrentTaskUsed(taskId, plateNumber) + } +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningAdapter.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningAdapter.kt new file mode 100644 index 0000000000..11541c764e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningAdapter.kt @@ -0,0 +1,283 @@ +package com.mogo.och.unmanned.ui.taskrunning + +import android.animation.ArgbEvaluator +import android.content.Context +import android.graphics.drawable.GradientDrawable +import android.util.TypedValue +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.widget.AppCompatImageView +import androidx.appcompat.widget.AppCompatTextView +import androidx.recyclerview.widget.RecyclerView +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.data.bean.BusStationBean +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.ui.writeoff.WriteOffView +import me.jessyan.autosize.utils.AutoSizeUtils + +/** + * 路线列表adapter + */ +class TaskRunningAdapter( + private val mContext: Context, + val mData: MutableList +) : RecyclerView.Adapter() { + + companion object { + const val TAG = "${M_BUS}TaskRunningAdapter" + } + + private val argbEvaluator: ArgbEvaluator = ArgbEvaluator() + private val startColor = ResourcesUtils.getColor(R.color.shuttle_driver_1970FF) + private val endColor = ResourcesUtils.getColor(R.color.common_19FF7F) + private val heightItem = 100f + private val halfHeight = 16.5f + private var totalHeight = 0f + + fun setDataList(dataList: List) { + CallerLogger.d(TAG, "设置view-----") + this.mData.clear() + this.mData.addAll(dataList) + if (LineModel.startStationIndex == 0) { + totalHeight = 33 + (dataList.size - 2) * heightItem + } else { + totalHeight = + (halfHeight + (dataList.size - 1 - LineModel.startStationIndex) * heightItem).toFloat() + } + notifyDataSetChanged() + } + + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int + ): TaskRunningViewHolder { + val view = LayoutInflater.from(mContext).inflate( + R.layout.shuttle_unmanned_running_station_list_item, parent, false + ) + return TaskRunningViewHolder(view) + } + + override fun onBindViewHolder(holder: TaskRunningViewHolder, position: Int) { + val currentPosition = holder.bindingAdapterPosition + val line = mData[currentPosition] + holder.actvStationName.text = line.name + holder.actvWriteOffCount.setSiteId(line.siteId) + val startStationIndex = LineModel.startStationIndex //当前站点 + if (startStationIndex > 0) { + CallerLogger.d(TAG, "位置:$currentPosition 当前站${mData[startStationIndex]} ") + } + + if (currentPosition < startStationIndex) { + holder.actvStationName.setTextSize( + TypedValue.COMPLEX_UNIT_PX, + AutoSizeUtils.dp2px(mContext, 40f).toFloat() + ) + holder.actvStationName.setTextColor(ResourcesUtils.getColor(R.color.bus_color_4dffffff)) + holder.actvWriteOffCount.visibility = View.GONE + holder.acivStationHead.setImageResource(R.drawable.unmanned_bus_switch_line_adapter_point_pass) + } else if (currentPosition == startStationIndex) { + holder.actvStationName.setTextSize( + TypedValue.COMPLEX_UNIT_PX, + AutoSizeUtils.dp2px(mContext, 45f).toFloat() + ) + holder.actvStationName.setTextColor(ResourcesUtils.getColor(R.color.bus_color_2EACFF)) +// if (LineModel.startStationIndex == mData.size - 1) { + if (LineModel.isLastStation() == true) { + holder.actvWriteOffCount.visibility = View.GONE + } else { + holder.actvWriteOffCount.visibility = View.VISIBLE + } + holder.acivStationHead.setImageResource(R.drawable.unmanned_bus_runnint_task_middle) + } else { + holder.actvStationName.setTextColor(ResourcesUtils.getColor(R.color.white)) + holder.actvStationName.setTextSize( + TypedValue.COMPLEX_UNIT_PX, + AutoSizeUtils.dp2px(mContext, 40f).toFloat() + ) + holder.itemView.background = null + holder.actvWriteOffCount.visibility = View.GONE + holder.acivStationHead.setImageResource(R.drawable.unmanned_bus_runnint_task_middle) + } + holder.stationStatus.visibility = if (line.tag == 2) { + holder.actvStationName.setTextSize( + TypedValue.COMPLEX_UNIT_PX, + AutoSizeUtils.dp2px(mContext, 40f).toFloat() + ) + holder.actvStationName.setTextColor(ResourcesUtils.getColor(R.color.bus_color_4dffffff)) + holder.actvWriteOffCount.visibility = View.GONE + holder.acivStationHead.setImageResource(R.drawable.unmanned_bus_switch_line_adapter_point_pass) + View.VISIBLE + } else { + View.GONE + } + + when (currentPosition) { + 0 -> { + holder.acivStationHeadBig.visibility = View.VISIBLE + holder.acivStationHead.visibility = View.INVISIBLE + holder.acivStationHeadBig.setImageResource(R.drawable.unmanned_bus_runnint_task_start) + holder.middleStationBg.visibility = View.GONE + holder.startStationBg.visibility = View.VISIBLE + holder.endStationBg.visibility = View.GONE + if (startStationIndex == 0) { + if (line.isLeaving) { + // 下端 灰色 + holder.startStationBg.setBackgroundResource(R.color.shuttle_driver_4DFFFFFF) + holder.itemView.background = null + } else { + // 下端 彩色 + holder.itemView.setBackgroundResource(R.drawable.unmanned_bus_task_current_station_bg) + + val orientation = GradientDrawable.Orientation.TOP_BOTTOM + val temp01 = GradientDrawable( + orientation, intArrayOf( + startColor, + endColor + ) + ) + holder.startStationBg.background = temp01 + } + } else { + // 下端 灰色 + holder.startStationBg.setBackgroundResource(R.color.shuttle_driver_4DFFFFFF) + holder.itemView.background = null + } + } + + mData.size - 1 -> { + holder.acivStationHeadBig.visibility = View.VISIBLE + holder.acivStationHead.visibility = View.INVISIBLE + holder.acivStationHeadBig.setImageResource(R.drawable.unmanned_bus_runnint_task_end) + holder.middleStationBg.visibility = View.GONE + holder.startStationBg.visibility = View.GONE + holder.endStationBg.visibility = View.VISIBLE + if (startStationIndex == itemCount - 1) { + if (line.isLeaving) { + holder.endStationBg.setBackgroundResource(R.color.shuttle_driver_4DFFFFFF) + holder.itemView.setBackgroundResource(R.drawable.unmanned_bus_task_current_station_bg) + } else { + holder.itemView.setBackgroundResource(R.drawable.unmanned_bus_task_current_station_bg) + holder.endStationBg.setBackgroundResource(R.color.shuttle_driver_4DFFFFFF) + } + } else { + // 上端 彩色 + holder.itemView.background = null + val startColorTemp = argbEvaluator.evaluate( + ((totalHeight - halfHeight) / totalHeight).toFloat(), + startColor, + endColor + ) as Int + val endColorTemp = argbEvaluator.evaluate(1f, startColor, endColor) as Int + val orientation = GradientDrawable.Orientation.TOP_BOTTOM + val temp01 = GradientDrawable( + orientation, intArrayOf( + startColorTemp, + endColorTemp + ) + ) + holder.endStationBg.background = temp01 + } + } + + else -> { + holder.acivStationHeadBig.visibility = View.GONE + holder.acivStationHead.visibility = View.VISIBLE + holder.middleStationBg.visibility = View.VISIBLE + holder.startStationBg.visibility = View.GONE + holder.endStationBg.visibility = View.GONE + if (currentPosition == startStationIndex) { + if (line.isLeaving) { + // 灰色 + holder.middleStationBg.setBackgroundResource(R.color.shuttle_driver_4DFFFFFF) + holder.itemView.background = null + } else { + // 彩色 + holder.itemView.setBackgroundResource(R.drawable.unmanned_bus_task_current_station_bg) + val startColorTemp = argbEvaluator.evaluate(0f, startColor, endColor) as Int + val endColorTemp = + argbEvaluator.evaluate(100f / totalHeight, startColor, endColor) as Int + val orientation = GradientDrawable.Orientation.TOP_BOTTOM + val temp01 = GradientDrawable( + orientation, intArrayOf( + startColorTemp, + endColorTemp + ) + ) + holder.middleStationBg.background = temp01 + } + } else if (currentPosition < startStationIndex) { + // 灰色 + holder.middleStationBg.setBackgroundResource(R.color.shuttle_driver_4DFFFFFF) + holder.itemView.background = null + } else { + var dex = 0f + if (startStationIndex == 0) { + val firstItemData = mData[0] + if (!firstItemData.isLeaving) { + dex = halfHeight + } + } else { + val checkIndex = mData.get(startStationIndex) + if (!checkIndex.isLeaving) { + dex = heightItem + } + } + // 彩色 + holder.itemView.background = null + val index = (currentPosition - startStationIndex - 1) * 100 + val startFraction = (dex + index) / totalHeight + val endFraction = (dex + index + 100) / totalHeight + CallerLogger.d( + TAG, + "位置:$currentPosition 当前站${startStationIndex} 开始百分比:${startFraction} 结束百分比:${endFraction}" + ) + val startColorTemp = + argbEvaluator.evaluate(startFraction, startColor, endColor) as Int + val endColorTemp = + argbEvaluator.evaluate(endFraction, startColor, endColor) as Int + val orientation = GradientDrawable.Orientation.TOP_BOTTOM + val temp01 = GradientDrawable( + orientation, intArrayOf( + startColorTemp, + endColorTemp + ) + ) + holder.middleStationBg.background = temp01 + } + } + } + if (currentPosition == LineModel.nextStationIndex) { + val preLine = mData[startStationIndex] + if (preLine.isLeaving) { + holder.itemView.setBackgroundResource(R.drawable.unmanned_bus_task_current_station_bg) + } else { + holder.itemView.background = null + } + } + + } + + override fun getItemCount(): Int { + return mData.size + } + + class TaskRunningViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val actvStationName: AppCompatTextView = itemView.findViewById(R.id.unmanned_actv_station_name)//站点名称 + val acivStationHead: AppCompatImageView = + itemView.findViewById(R.id.unmanned_aciv_station_head)//普通站点标识 不是起始和终点坐标 + val stationStatus: AppCompatTextView = itemView.findViewById(R.id.unmanned_station_status)//站点状态 + val acivStationHeadBig: AppCompatImageView = + itemView.findViewById(R.id.unmanned_aciv_station_head_big)//起始和终点坐标标识 + val actvWriteOffCount: WriteOffView = + itemView.findViewById(R.id.unmanned_actv_write_off_count) //此战核销的人数 + val middleStationBg: View = itemView.findViewById(R.id.unmanned_bg_pass_bg) //贯通背景调 + val endStationBg: View = itemView.findViewById(R.id.unmanned_bg_pass_head_bg) //终点的背景 + val startStationBg: View = itemView.findViewById(R.id.unmanned_bg_pass_bottom_bg) //起点坐标的背景 + + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningModel.kt new file mode 100644 index 0000000000..ae592b2f3b --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningModel.kt @@ -0,0 +1,84 @@ +package com.mogo.och.unmanned.ui.taskrunning + +import androidx.lifecycle.ViewModel +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.unmanned.callback.IBusLinesCallback +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.model.OrderModel + +/** + * @author XuXinChao + * @description BadCase录包管理页面 + * @since: 2022/12/15 + */ +class TaskRunningModel : ViewModel(), IBusLinesCallback { + + private val TAG = M_BUS + TaskRunningModel::class.java.simpleName + + private var viewCallback: SwtichLineViewCallback? = null + + + override fun onCleared() { + } + + fun setDistanceCallback(viewCallback: SwtichLineViewCallback) { + this.viewCallback = viewCallback + LineModel.setBusLinesCallback(TAG, this) + } + + fun leaveStation() { + OrderModel.driveToNextStation() + } + + interface SwtichLineViewCallback { + fun showRunningTaskInfo() + fun hideLoadingAndshowRunningTaskInfo() + fun smoothScrollToPosition(position: Int) + fun completeTaskFail() + } + + override fun onLeaveStaionSuccess() { + BizLoopManager.runInMainThread { + viewCallback?.hideLoadingAndshowRunningTaskInfo() + smoothScrollToPosition() + } + + } + + fun smoothScrollToPosition() { + BizLoopManager.runInMainThread(object : Runnable { + override fun run() { + viewCallback?.smoothScrollToPosition(LineModel.startStationIndex) + } + }) + } + + fun arriveStation() { + OrderModel.onArriveAt(null, "页面触发到站") + } + + override fun onArriveStationSuccess() { + BizLoopManager.runInMainThread { + smoothScrollToPosition() + viewCallback?.showRunningTaskInfo() + } + } + + override fun onCompleteTask() { + + } + + override fun onCompleteTaskFail() { + super.onCompleteTaskFail() + BizLoopManager.runInMainThread { + viewCallback?.completeTaskFail() + } + } + + fun completeTask() { + OrderModel.completeTask(false) + } + +} + diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningView.kt new file mode 100644 index 0000000000..b534db4a0e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/taskrunning/TaskRunningView.kt @@ -0,0 +1,180 @@ +package com.mogo.och.unmanned.ui.taskrunning + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.wigets.CommonSlideView +import com.mogo.och.common.module.wigets.WrapContentLinearLayoutManager +import com.mogo.och.common.module.wigets.dialog.CommonDialogStatus +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.ui.bizswitch.SwtichBizModel +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_aciv_task_leave_station_slide_bg +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_actv_arriver_station +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_actv_complete_task +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_actv_running_task_last_station +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_actv_running_task_time +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_bus_task_running_line_name +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_loading_arrive_station +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_rl_running_task_station_list +import kotlinx.android.synthetic.main.shuttle_unmanned_task_running.view.unmanned_task_running_layout_btn + +/** + * OCH业务的任务 + */ +class TaskRunningView : ConstraintLayout, TaskRunningModel.SwtichLineViewCallback { + + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super( + context, + attributeSet, + defStyleAttr + ) + + constructor( + context: Context, + attributeSet: AttributeSet, + defStyleAttr: Int, + defStyleRes: Int + ) : super(context, attributeSet, defStyleAttr, defStyleRes) + + + companion object { + const val TAG = M_BUS + "TaskRunningView" + } + + private var viewModel: TaskRunningModel? = null + private var viewbizModel: SwtichBizModel? = null + + private lateinit var mAdapter: TaskRunningAdapter + + private lateinit var linearLayoutManager: WrapContentLinearLayoutManager + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_task_running, this, true) + initView() + } + + private fun initView() { + linearLayoutManager = WrapContentLinearLayoutManager(context) + unmanned_rl_running_task_station_list.setLayoutManager(linearLayoutManager) + mAdapter = TaskRunningAdapter(context, mutableListOf()) + unmanned_rl_running_task_station_list.setAdapter(mAdapter) + unmanned_aciv_task_leave_station_slide_bg.setSlideListener(object : CommonSlideView.SlideListener { + override fun slideEnd() { + viewModel?.leaveStation() + } + }) + unmanned_actv_arriver_station.onClick { + unmanned_loading_arrive_station.visibility = VISIBLE + viewModel?.arriveStation() + } + unmanned_actv_complete_task.onClick { + CallerLogger.d(TAG, "启动自驾参数:${LineManager.initAutopilotControlParameters()}") + val builder = CommonDialogStatus.Builder() + val closeLineConfirmDialog = builder + .title(ResourcesUtils.getString(R.string.unmanned_bus_dialog_title)) + .tips(ResourcesUtils.getString(R.string.unmanned_bus_dialog_tips)) + .confirmStr(ResourcesUtils.getString(R.string.unmanned_bus_dialog_confirm)) + .cancelStr(ResourcesUtils.getString(R.string.unmanned_bus_dialog_cancel)) + .status(CommonDialogStatus.Status.ask) + .build(context) + closeLineConfirmDialog.setClickListener(object : CommonDialogStatus.ClickListener { + override fun confirm() { + viewModel?.completeTask() + } + + override fun cancel() { + closeLineConfirmDialog.dismiss() + } + }) + closeLineConfirmDialog.show() + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(TaskRunningModel::class.java) + } + viewbizModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(SwtichBizModel::class.java) + } + + viewModel?.setDistanceCallback(this) + } + + override fun showRunningTaskInfo() { + LineManager.getLineInfo { lineInfo -> + unmanned_bus_task_running_line_name.text = lineInfo.lineName + } +// unmanned_actv_running_task_time.text = "班次:${LineModel.getTaskTime()}" + unmanned_actv_running_task_time.text = "${StringUtils.getString(R.string.module_och_classes)}${LineModel.getTaskTime()}" + LineModel.stationList?.takeIf { it.size >= 2 }?.let { +// unmanned_actv_running_task_last_station.text = "→ ${it.last().name ?: ""}" + unmanned_actv_running_task_last_station.text = StringUtils.getString(R.string.unmanned_bus_leave_for, it.last().name + ?: "") + mAdapter.setDataList(it) + CallerLogger.d( + TAG, + "BusLineModel.startStationIndex:${LineModel.startStationIndex}___$it" + ) + val currentStation = it.get(LineModel.startStationIndex) + if (currentStation.isLeaving) { + showArriverStationAndCompleteTask() + } else { + showLeaveStationView() + } +// if (LineModel.startStationIndex == it.size - 1) { + if (LineModel.isLastStation() == true) { +// unmanned_aciv_task_leave_station_slide_bg.setTextValue("单程结束") + unmanned_aciv_task_leave_station_slide_bg.setTextValue(StringUtils.getString(R.string.module_och_one_way_completion)) + } else { +// unmanned_aciv_task_leave_station_slide_bg.setTextValue("滑动出发") + unmanned_aciv_task_leave_station_slide_bg.setTextValue(StringUtils.getString(R.string.module_och_slide_moving)) + } + } + } + + override fun hideLoadingAndshowRunningTaskInfo() { + unmanned_loading_arrive_station.visibility = GONE + showRunningTaskInfo() + } + + override fun completeTaskFail() { + unmanned_aciv_task_leave_station_slide_bg.reset() + } + + override fun smoothScrollToPosition(position: Int) { + try { + unmanned_rl_running_task_station_list.smoothScrollToPosition(position) + } catch (e: Exception) { + OchChainLogManager.writeChainLog("错误", "e:${e.message}") + } + + } + + private fun showLeaveStationView() { + unmanned_aciv_task_leave_station_slide_bg.visibility = VISIBLE + unmanned_task_running_layout_btn.visibility = GONE + } + + private fun showArriverStationAndCompleteTask() { + unmanned_aciv_task_leave_station_slide_bg.visibility = INVISIBLE + unmanned_task_running_layout_btn.visibility = VISIBLE + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/widget/UnmannedMoreView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/widget/UnmannedMoreView.kt new file mode 100644 index 0000000000..fa3d571953 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/widget/UnmannedMoreView.kt @@ -0,0 +1,44 @@ +package com.mogo.och.unmanned.ui.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.och.shuttle.unmanned.R +import kotlinx.android.synthetic.main.shuttle_unmanned_more.view.unmannedMoreClose + +/** + * 更多 + */ +class UnmannedMoreView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_more, this, true) + initView() + } + + private fun initView() { + unmannedMoreClose.setOnClickListener { + this@UnmannedMoreView.visibility = View.GONE + + } + + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/widget/UnmannedMsgBoxView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/widget/UnmannedMsgBoxView.kt new file mode 100644 index 0000000000..a00a9fe19f --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/widget/UnmannedMsgBoxView.kt @@ -0,0 +1,193 @@ +package com.mogo.och.unmanned.ui.widget + +import android.app.Activity +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.LinearLayoutManager +import com.mogo.eagle.core.data.enums.DataSourceType +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.data.msgbox.MsgCategory +import com.mogo.eagle.core.function.api.datacenter.IDataCenterBizListener +import com.mogo.eagle.core.function.api.datacenter.msgbox.IMsgBoxEventListener +import com.mogo.eagle.core.function.api.datacenter.msgbox.IMsgBoxListener +import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager +import com.mogo.eagle.core.function.hmi.bone.tab.adapter.MsgBoxTabAdapter +import com.mogo.eagle.core.utilcode.util.ResourceUtils.getDrawable +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.shuttle.unmanned.R +import kotlinx.android.synthetic.main.shuttle_unmanned_msg_box.view.btnUnmannedMsgBoxMore +import kotlinx.android.synthetic.main.shuttle_unmanned_msg_box.view.rvUnmannedMsgBoxList +import kotlinx.android.synthetic.main.shuttle_unmanned_msg_box.view.unmannedLayoutMore +import kotlinx.android.synthetic.main.shuttle_unmanned_msg_box.view.unmannedMsgBoxEmpty +import org.greenrobot.eventbus.EventBus +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode + +/** + * 无人化消息盒子 + */ +class UnmannedMsgBoxView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener, IMsgBoxEventListener, IDataCenterBizListener { + companion object { + private const val TAG = "UnmannedMsgBoxView" + private val noticeList: MutableList = mutableListOf() + } + + init { + LayoutInflater.from(context).inflate(R.layout.shuttle_unmanned_msg_box, this, true) + initView() + } + + private var msgBoxTabAdapter: MsgBoxTabAdapter? = null + private var linearLayoutManager: LinearLayoutManager? = null + private var isShowSummary = false //是否展示汇总消息 + + private fun initView() { + msgBoxTabAdapter = MsgBoxTabAdapter(context as Activity) + rvUnmannedMsgBoxList.adapter = msgBoxTabAdapter + linearLayoutManager = LinearLayoutManager(context) + linearLayoutManager?.orientation = LinearLayoutManager.VERTICAL + rvUnmannedMsgBoxList.layoutManager = linearLayoutManager + val divider = DividerItemDecoration(context, linearLayoutManager!!.orientation) + getDrawable(R.drawable.rv_divider_line_tab)?.let { divider.setDrawable(it) } + rvUnmannedMsgBoxList.addItemDecoration(divider) + //获取通知消息列表 + CallerMsgBoxManager.getCachedNotifyData()?.let { + noticeList.addAll(it) + } + // 获取车辆系统信息 + CallerMsgBoxManager.getCachedSysInfoData()?.let { + noticeList.addAll(it) + } + // 获取 BadCase + CallerMsgBoxManager.getCachedRecordBagData()?.let { + noticeList.addAll(it) + } + // 排序 + if (noticeList.isNotEmpty()) { + noticeList.sortByDescending { it.timestamp } + } + msgBoxTabAdapter?.setData(noticeList) + notifyData(true) + btnUnmannedMsgBoxMore.setOnClickListener { + if (unmannedLayoutMore.visibility == View.VISIBLE) { + unmannedLayoutMore.visibility = View.GONE + } else { + unmannedLayoutMore.visibility = View.VISIBLE + } + } + } + + + private fun notifyData(isScroll: Boolean = false) { + if (noticeList.isEmpty()) { + if (unmannedMsgBoxEmpty.visibility != View.VISIBLE) { + rvUnmannedMsgBoxList.visibility = View.GONE + unmannedMsgBoxEmpty.visibility = View.VISIBLE + } + } else { + if (rvUnmannedMsgBoxList.visibility != View.VISIBLE) { + unmannedMsgBoxEmpty.visibility = View.GONE + rvUnmannedMsgBoxList.visibility = View.VISIBLE + } + if (isScroll) + rvUnmannedMsgBoxList.scrollToPosition(0) + else { + msgBoxTabAdapter?.setData(noticeList) + } + } + } + + @Subscribe(threadMode = ThreadMode.MAIN) + fun notifyList(msgBoxList: MsgBoxBean) { + msgBoxTabAdapter?.notifyItemRemoved(noticeList.indexOf(msgBoxList)) + noticeList.remove(msgBoxList) + notifyData() + } + + override fun onDataChanged(category: MsgCategory, msgBoxList: MsgBoxBean) { + UiThreadHandler.post({ + when (category) { + //通知 + MsgCategory.NOTICE -> { + if (msgBoxList.sourceType == DataSourceType.SUMMARY) { + //在一次订单中汇总消息只展示一次 + if (isShowSummary) { + noticeList.add(0, msgBoxList) +// msgBoxTabAdapter?.notifyItemInserted(0) + isShowSummary = false + } + } else { + noticeList.add(0, msgBoxList) +// msgBoxTabAdapter?.notifyItemInserted(0) + } + } + + else -> { + noticeList.add(0, msgBoxList) +// msgBoxTabAdapter?.notifyItemInserted(0) + } + } + notifyData() + }, UiThreadHandler.MODE.QUEUE) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerMsgBoxListenerManager.addListener(TAG, this) + CallerMsgBoxEventListenerManager.addListener(TAG, this) + CallerDataCenterBizListener.addListener(TAG, this) + EventBus.getDefault().register(this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + unmannedLayoutMore.visibility = View.GONE + CallerMsgBoxListenerManager.removeListener(TAG) + CallerMsgBoxEventListenerManager.removeListener(TAG) + CallerDataCenterBizListener.removeListener(TAG) + EventBus.getDefault().unregister(this) + } + + + override fun onSummaryClickEvent() { + + } + + override fun onUpdateTipEvent(isShow: Boolean) { + + } + + override fun onBubbleOperationClickEvent(msgBoxBean: MsgBoxBean) { + + } + + override fun onBubbleV2XClickEvent(msgBoxBean: MsgBoxBean) { + + } + + override fun onBubbleReportClickEvent(msgBoxBean: MsgBoxBean) { + + } + + override fun invokeOrderStatus(inOrder: Boolean) { + isShowSummary = inOrder + } + + override fun onVisibilityChanged(changedView: View, visibility: Int) { + super.onVisibilityChanged(changedView, visibility) + if (visibility == View.VISIBLE) { + } + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/writeoff/WriteOffView.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/writeoff/WriteOffView.kt new file mode 100644 index 0000000000..537760dad7 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/writeoff/WriteOffView.kt @@ -0,0 +1,85 @@ +package com.mogo.och.unmanned.ui.writeoff + +import android.content.Context +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatTextView +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.findViewTreeViewModelStoreOwner +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.repository.RepositoryManager + +class WriteOffView : AppCompatTextView, WriteOffViewModel.IwriteOffViewCallback { + + private val TAG = M_BUS + "WriteOffView" + + constructor(context: Context) : super(context) + + constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) + + constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super( + context, + attributeSet, + defStyleAttr + ) + + private var viewModel: WriteOffViewModel? = null + + private var siteId: Int = 0 + + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + if (RepositoryManager.supportWriteOff()) { + val showText = + AbsMogoApplication.getApp().getString(R.string.unmanned_shuttle_write_off_count, 0) + text = showText + } + viewModel = findViewTreeViewModelStoreOwner()?.let { + ViewModelProvider(it).get(WriteOffViewModel::class.java) + } + } + + private fun startListenerWriteOff() { + viewModel?.setWriteOffCallback(this) + } + + private fun stopListenerWriteOff() { + viewModel?.setWriteOffCallback(null) + if (RepositoryManager.supportWriteOff()) { + val showText = + AbsMogoApplication.getApp().getString(R.string.unmanned_shuttle_write_off_count, 0) + text = showText + } + } + + override fun onVisibilityAggregated(isVisible: Boolean) { + super.onVisibilityAggregated(isVisible) + if (isVisible) { + startListenerWriteOff() + } else { + stopListenerWriteOff() + } + } + + init { + try { + + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun setWriteOffCount(showText: String, siteId: Int) { + if (this.siteId == siteId) { + text = showText + } + } + + fun setSiteId(siteId: Int) { + this.siteId = siteId + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/writeoff/WriteOffViewModel.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/writeoff/WriteOffViewModel.kt new file mode 100644 index 0000000000..80833292d2 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/ui/writeoff/WriteOffViewModel.kt @@ -0,0 +1,72 @@ +package com.mogo.och.unmanned.ui.writeoff + +import androidx.lifecycle.ViewModel +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.och.common.module.utils.RxUtils +import com.mogo.och.shuttle.unmanned.R +import com.mogo.och.unmanned.model.TicketModel +import io.reactivex.Observable +import io.reactivex.Observer +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable + +class WriteOffViewModel : ViewModel() { + + private val TAG = M_BUS + WriteOffViewModel::class.java.simpleName + + private var viewCallback: IwriteOffViewCallback? = null + + init { + + } + + private var disposable: Disposable? = null + + private val observer = object : Observer> { + override fun onSubscribe(d: Disposable) { + disposable = d + } + + override fun onError(e: Throwable) { + + } + + override fun onComplete() { + + } + + override fun onNext(countInfo: Pair) { + viewCallback?.setWriteOffCount(countInfo.first, countInfo.second) + } + + } + + fun setWriteOffCallback(viewCallback: IwriteOffViewCallback?) { + this.viewCallback = viewCallback + if (viewCallback == null) { + RxUtils.disposeSubscribe(disposable) + } + TicketModel + .getWriteOffCountObservable() + .flatMap { t -> + val showText = + AbsMogoApplication.getApp() + .getString(R.string.unmanned_shuttle_write_off_count, t.second) + Observable.just(Pair(showText, t.first)) + } + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(observer) + } + + override fun onCleared() { + super.onCleared() + this.viewCallback = null + RxUtils.disposeSubscribe(disposable) + } + + interface IwriteOffViewCallback { + fun setWriteOffCount(count: String, siteId: Int) + } + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/BusAnalyticsManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/BusAnalyticsManager.kt new file mode 100644 index 0000000000..845acfca79 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/BusAnalyticsManager.kt @@ -0,0 +1,49 @@ +package com.mogo.och.unmanned.util + +import com.mogo.och.bridge.autopilot.autopilot.IOchEventKey + + +/** + * OCH Bus埋点工具 + * + * + * Created on 2022/3/24 + */ +object BusAnalyticsManager : IOchEventKey { + + // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 + private const val EVENT_KEY_AP_UNABLE_START_REASON = + "event_key_och_bus_ap_unable_start_reason" + + // 埋点key:接管后点击'自动驾驶'按钮启动 + private const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot" + + // 埋点key:开始服务开启自动驾驶(成功/失败) + private const val EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service" + + //埋点key:订单结束 + private const val EVENT_KEY_STOP_SERVICE = "event_key_och_bus_stop_service" + + // 埋点key:点击启动自驾 + private const val EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_shuttle_click_start_autopilot" + + override fun getEventKeyStartService(): String { + return EVENT_KEY_START_SERVICE + } + + override fun getEventKeyRestartService(): String { + return EVENT_KEY_RESTART_AUTOPILOT + } + + override fun getEventKeyApUnableStartReason(): String { + return EVENT_KEY_AP_UNABLE_START_REASON + } + + override fun getEventKeyClickStartAutopilot(): String { + return EVENT_KEY_CLICK_START_AUTOPILOT + } + + override fun getEventKeyCompleteTask(): String? { + return EVENT_KEY_STOP_SERVICE + } +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/BusTrajectoryManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/BusTrajectoryManager.kt new file mode 100644 index 0000000000..1b82741bec --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/BusTrajectoryManager.kt @@ -0,0 +1,170 @@ +package com.mogo.och.unmanned.util + +import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS +import com.mogo.eagle.core.utilcode.util.GsonUtils +import com.mogo.och.bridge.autopilot.line.LineManager +import com.mogo.och.bridge.trajectory.ITrajectoryListListener +import com.mogo.och.bridge.trajectory.TrajectoryManager +import com.mogo.och.common.module.biz.login.LoginStatusManager.isLogin +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.unmanned.constant.BusConst +import com.mogo.och.unmanned.model.LineModel +import com.mogo.och.unmanned.model.LineModel.currentTask +import com.mogo.och.unmanned.model.LineModel.startStationIndex +import com.mogo.och.unmanned.model.OrderModel.isGoingToNextStation +import io.reactivex.Observable +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.disposables.Disposable +import io.reactivex.functions.Function +import io.reactivex.schedulers.Schedulers +import java.util.concurrent.TimeUnit + +/** + * Bus轨迹管理:给MEC下发用于轨迹下载的信息 + * Created on 2022/6/23 + */ +object BusTrajectoryManager : ITrajectoryListListener { + + private val TAG: String = M_BUS + BusTrajectoryManager::class.java.simpleName + + private var mAutopilotControlParameters: AutopilotControlParameters? = null + private var mSendReqDisposable: Disposable? = null + + init { + mAutopilotControlParameters = AutopilotControlParameters() + } + + fun load() { + TrajectoryManager.addListener(TAG, this) + } + + fun release() { + TrajectoryManager.removeListener(TAG) + } + + + /** + * 同步Bus路线信息 + */ + fun syncTrajectoryInfo() { + if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null) { + OchChainLogManager.writeChainLogTrajectory("轨迹监控", "开始或者结束下发轨迹 轨迹id:-1") + } else { + OchChainLogManager.writeChainLogTrajectory( + "轨迹监控", + "开始或者结束下发轨迹 轨迹id:${mAutopilotControlParameters!!.autoPilotLine!!.lineId}____${startStationIndex}" + ) + } + val pos = LineModel.stationList?.indexOfFirst { it.tag != 2 } + if (isLogin() && currentTask != null && !isGoingToNextStation && (startStationIndex == 0 || startStationIndex == pos)) { + d(TAG, "syncTrajectoryInfo() start.") + startTrajReqLoop() + } else { + // 无路线信息or当前未在始发站 + d(TAG, "syncTrajectoryInfo() stop.") + stopTrajReqLoop() + } + } + + override fun onDownLoadStart(lineId: Long) { + stopTrajReqLoop() + } + + override fun onDownLoadSuccess(lineId: Long) { + stopTrajReqLoop() + } + + override fun onDownLoadReady(lineId: Long) { + syncTrajectoryInfo() + } + + private fun setupAutoPilotLine() { + if (LineManager.contraiInfo == null || LineManager.lineInfos == null) { + e( + TAG, + "下发轨迹报错:没有轨迹或线路信息 contraiInfo:${LineManager.contraiInfo} lineInfos:${LineManager.lineInfos}" + ) + } else { + mAutopilotControlParameters = LineManager.initAutopilotControlParametersFromContrai() + } + } + + private fun clearAutoPilotLine() { + if (mAutopilotControlParameters == null) return + mAutopilotControlParameters = null + } + + private fun startTrajReqLoop() { + if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null) { + OchChainLogManager.writeChainLogTrajectory("轨迹监控", "开始下发轨迹 轨迹id:-1") + } else { + OchChainLogManager.writeChainLogTrajectory( + "轨迹监控", + "开始下发轨迹 轨迹id:${mAutopilotControlParameters?.autoPilotLine?.lineId}" + ) + } + if (mSendReqDisposable != null && !mSendReqDisposable!!.isDisposed) { + return + } + d(TAG, "startTrajReqLoop()") + setupAutoPilotLine() + mSendReqDisposable = Observable.interval( + BusConst.LOOP_DELAY, BusConst.LOOP_PERIOD_10S, TimeUnit.MILLISECONDS + ).map((Function { aLong: Long -> aLong + 1 })).subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()).subscribe { aLong: Long -> + if (aLong > BusConst.LOOP_SEND_TRAJ_TIMES) { + stopTrajReqLoop() + return@subscribe + } + d(TAG, "loop sendTrajectoryReq: $aLong") + sendTrajectoryReq() + } + } + + fun stopTrajReqLoop() { + if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null) { + OchChainLogManager.writeChainLogTrajectory("轨迹监控", "结束下发轨迹 轨迹id:-1") + } else { + OchChainLogManager.writeChainLogTrajectory( + "轨迹监控", + "结束下发轨迹 轨迹id:${mAutopilotControlParameters!!.autoPilotLine!!.lineId}" + ) + } + if (mSendReqDisposable != null) { + d(TAG, "stopTrajReqLoop()") + mSendReqDisposable!!.dispose() + mSendReqDisposable = null + clearAutoPilotLine() + } + } + + /** + * download 加orderid + * fsm 回传orderid + * 下载轨迹 添加回执超时处理 + */ + private fun sendTrajectoryReq() { + if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null || mAutopilotControlParameters!!.autoPilotLine!!.lineId == -1L) { + e(TAG, "下发轨迹报错:自己参数:${mAutopilotControlParameters}") + setupAutoPilotLine() + if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null || mAutopilotControlParameters!!.autoPilotLine!!.lineId == -1L) { + return + } + } + mAutopilotControlParameters?.let { + OchChainLogManager.writeChainLogTrajectory( + "轨迹监控", + "sendTrajectoryReq() 下发轨迹:${GsonUtils.toJson(mAutopilotControlParameters)}" + ) + CallerAutoPilotControlManager.sendTrajectoryDownloadReq(it, 0) + } + + i(TAG, "sendTrajectoryReq(): " + GsonUtils.toJson(mAutopilotControlParameters)) + } + +} diff --git a/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/ShuttleVoiceManager.kt b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/ShuttleVoiceManager.kt new file mode 100644 index 0000000000..f3e9c1684d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/java/com/mogo/och/unmanned/util/ShuttleVoiceManager.kt @@ -0,0 +1,160 @@ +package com.mogo.och.unmanned.util + +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.voice.AIAssist +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.och.common.module.biz.media.VoiceNotice +import com.mogo.och.common.module.manager.socket.lan.LanSocketManager +import com.mogo.och.common.module.manager.socket.lan.bean.AppConnectMsg +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.shuttle.unmanned.R +import com.mogo.skin.utils.SkinResources +import com.mogo.tts.base.LangTtsEntity +import com.mogo.tts.base.LanguageType + +object ShuttleVoiceManager { + + fun arrivedStationOut(notice: String?) { + if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) { + VoiceNotice.showNoticeOut(notice) + } + } + + fun arrivedStationBus(siteNameCN: String?, siteNameKR: String?) { + val context = AbsMogoApplication.getApp() + val list: MutableList = ArrayList() + siteNameCN?.let { + val chineseTTS = LangTtsEntity( + context.getString(R.string.unmanned_bus_arrived_station_tip, it), + LanguageType.CHINESE + ) + val engTTS = LangTtsEntity( + context.getString(R.string.unmanned_bus_arrived_station_english_tip, it), + LanguageType.ENGLISH + ) + val koreanTTS = LangTtsEntity( + context.getString(R.string.unmanned_bus_arrived_station_korean_tip, siteNameKR + ?: it), + LanguageType.KOREAN + ) + list.add(chineseTTS) + list.add(engTTS) + list.add(koreanTTS) + + } + + if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) { + VoiceNotice.showNotice(list, AIAssist.LEVEL1, null) + } else if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) { + siteNameCN?.let { + sendPassengerPlay(ResourcesUtils.getString(R.string.unmanned_bus_arrived_station_tip, it)) + } + } + } + + fun leaveStationBus(siteNameCN: String?, siteNameKR: String?) { + val list: MutableList = ArrayList() + val context = AbsMogoApplication.getApp() + siteNameCN?.let { + val chineseTTS = LangTtsEntity( + context.getString(R.string.unmanned_bus_leave_station_tip, it), + LanguageType.CHINESE + ) + val engTTS = LangTtsEntity( + context.getString(R.string.unmanned_bus_leave_station_english_tip, it), + LanguageType.ENGLISH + ) + list.add(chineseTTS) + list.add(engTTS) + + val koreanTTS = LangTtsEntity( + context.getString(R.string.unmanned_bus_leave_station_korean_tip, siteNameKR + ?: it), + LanguageType.KOREAN + ) + + list.add(koreanTTS) + } + + if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) { + VoiceNotice.showNotice(list, AIAssist.LEVEL1, null) + } else if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) { + siteNameCN?.let { + sendPassengerPlay(ResourcesUtils.getString(R.string.unmanned_bus_leave_station_tip, it)) + } + } + } + + fun endOrderBus() { + val context = AbsMogoApplication.getApp() + val list: MutableList = ArrayList() + val chineseTTS = LangTtsEntity(SkinResources.getInstance().getString(R.string.unmanned_bus_end_task_tip), LanguageType.CHINESE) + val engTTS = LangTtsEntity(context.getString(R.string.unmanned_bus_end_task_english_tip), LanguageType.ENGLISH) + val koreanTTS = LangTtsEntity(context.getString(R.string.unmanned_bus_end_task_korean_tip), LanguageType.KOREAN) + list.add(chineseTTS) + list.add(engTTS) + list.add(koreanTTS) + + if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) { + VoiceNotice.showNotice(list, AIAssist.LEVEL0, null) + } else if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) { + sendPassengerPlay(SkinResources.getInstance().getString(R.string.unmanned_bus_end_task_tip)) + } + + } + + + fun writeOffCount(successNum: Int) { + if (successNum <= 1) { +// VoiceNotice.showNotice("核验通过", AIAssist.LEVEL3) + VoiceNotice.showNotice(StringUtils.getString(R.string.module_och_verification_successful), AIAssist.LEVEL3) + } else { +// VoiceNotice.showNotice("$successNum 人核验通过", AIAssist.LEVEL3) + VoiceNotice.showNotice(StringUtils.getString(R.string.module_och_verification_successful1, successNum), AIAssist.LEVEL3) + } + } + + + // 距离发车还有1分钟 + fun showLeafTime(tips: String) { + //语音提示 + VoiceNotice.showNotice(tips) + } + + fun writeOffFaile(reaseon: String) { + VoiceNotice.showNotice(reaseon, AIAssist.LEVEL3) + } + + fun leave200Distance(message: String) { + if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) { + VoiceNotice.showNotice(message, AIAssist.LEVEL0) + } else if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) { + sendPassengerPlay(message) + } + } + + + fun collisionRisk() { + val message = ResourcesUtils.getString(R.string.unmanned_bus_voice_collision_risk) + if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) { + VoiceNotice.showNotice(message, AIAssist.LEVEL0) + } else if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) { + sendPassengerPlay(message) +// arrivedStationOut("车辆遇到紧急情况,正在安全处理") + arrivedStationOut(ResourcesUtils.getString(R.string.unmanned_bus_vehicle_emergency)) + } + } + + private fun sendPassengerPlay(msg: String) { + val passengerMsg = AppConnectMsg( + isViewShow = false, + isPlay = true, + msg = msg, + ) + LanSocketManager.sendMsgToClient(passengerMsg) + } + + +} \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/color/unmanned_bus_task_submit_text_color_selector.xml b/OCH/shuttle/driver_unmanned/src/main/res/color/unmanned_bus_task_submit_text_color_selector.xml new file mode 100644 index 0000000000..79820a2444 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/color/unmanned_bus_task_submit_text_color_selector.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/color/unmanned_bus_task_text_color_selector.xml b/OCH/shuttle/driver_unmanned/src/main/res/color/unmanned_bus_task_text_color_selector.xml new file mode 100644 index 0000000000..a658eceb21 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/color/unmanned_bus_task_text_color_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bg_msg_box.webp b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bg_msg_box.webp new file mode 100644 index 0000000000..fd981c686b Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bg_msg_box.webp differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_biz_bg.webp b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_biz_bg.webp new file mode 100644 index 0000000000..d2c5817d8d Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_biz_bg.webp differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_line_task_arrow.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_line_task_arrow.png new file mode 100644 index 0000000000..47c387eb9f Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_line_task_arrow.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_open_qr.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_open_qr.png new file mode 100644 index 0000000000..8bc5065349 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_open_qr.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_end.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_end.png new file mode 100644 index 0000000000..e54309848c Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_end.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_middle.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_middle.png new file mode 100644 index 0000000000..b2c4edba60 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_middle.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_start.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_start.png new file mode 100644 index 0000000000..dac86db75d Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_runnint_task_start.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_end.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_end.png new file mode 100644 index 0000000000..45071228a2 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_end.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_notarrive.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_notarrive.png new file mode 100644 index 0000000000..cbb2dda8b9 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_notarrive.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_pass.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_pass.png new file mode 100644 index 0000000000..a411050a6e Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_pass.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_start.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_start.png new file mode 100644 index 0000000000..baca87f72f Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_station_start.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_switch_line_adapter_point.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_switch_line_adapter_point.png new file mode 100644 index 0000000000..b2c4edba60 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_switch_line_adapter_point.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_switch_line_adapter_point_pass.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_switch_line_adapter_point_pass.png new file mode 100644 index 0000000000..7e70dbce57 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_switch_line_adapter_point_pass.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_weak_switch_task_bottom.9.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_weak_switch_task_bottom.9.png new file mode 100644 index 0000000000..a7f1ff5114 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_bus_weak_switch_task_bottom.9.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_more_bg.webp b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_more_bg.webp new file mode 100644 index 0000000000..77eededb37 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_more_bg.webp differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_msg_box_more_btn.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_msg_box_more_btn.png new file mode 100644 index 0000000000..82f3c79c9e Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_msg_box_more_btn.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_msg_box_more_close.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_msg_box_more_close.png new file mode 100644 index 0000000000..b63e47851c Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_msg_box_more_close.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_shuttle_weak_empty.png b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_shuttle_weak_empty.png new file mode 100644 index 0000000000..93393ca8d0 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/drawable-nodpi/unmanned_shuttle_weak_empty.png differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_running_task_arrive_station_selector.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_running_task_arrive_station_selector.xml new file mode 100644 index 0000000000..7b2b032236 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_running_task_arrive_station_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_running_task_complete_selector.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_running_task_complete_selector.xml new file mode 100644 index 0000000000..7b2b032236 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_running_task_complete_selector.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_shape_select_line_item_time_bg.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_shape_select_line_item_time_bg.xml new file mode 100644 index 0000000000..0160724d12 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_shape_select_line_item_time_bg.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_station_status_bg.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_station_status_bg.xml new file mode 100644 index 0000000000..9ce6bb662e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_station_status_bg.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_normal.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_normal.xml new file mode 100644 index 0000000000..7a6c396b3d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_normal.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_selected.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_selected.xml new file mode 100644 index 0000000000..c236e4a6e4 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_selected.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_selector.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_selector.xml new file mode 100644 index 0000000000..d57d10a7f7 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_line_selector.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_normal.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_normal.xml new file mode 100644 index 0000000000..7a6c396b3d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_normal.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_selected.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_selected.xml new file mode 100644 index 0000000000..ef6e5f4b3d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_selected.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_selector.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_selector.xml new file mode 100644 index 0000000000..45febaf0be --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_switch_task_selector.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_task_current_station_bg.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_task_current_station_bg.xml new file mode 100644 index 0000000000..4e40bdeac4 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_bus_task_current_station_bg.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_msg_box_more_btn_bg.xml b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_msg_box_more_btn_bg.xml new file mode 100644 index 0000000000..17560a2c09 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/drawable/unmanned_msg_box_more_btn_bg.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_base_fragment.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_base_fragment.xml new file mode 100644 index 0000000000..3b7431587c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_base_fragment.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_biz.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_biz.xml new file mode 100644 index 0000000000..aeeeb5b82e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_biz.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_container_view.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_container_view.xml new file mode 100644 index 0000000000..36cd51df2c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_container_view.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_error_view.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_error_view.xml new file mode 100644 index 0000000000..ee3ce57c34 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_error_view.xml @@ -0,0 +1,32 @@ + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_more.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_more.xml new file mode 100644 index 0000000000..6c5a81748c --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_more.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_msg_box.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_msg_box.xml new file mode 100644 index 0000000000..03f3993f69 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_msg_box.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_running_station_list_item.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_running_station_list_item.xml new file mode 100644 index 0000000000..84664b4127 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_running_station_list_item.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_biz.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_biz.xml new file mode 100644 index 0000000000..886f7787f5 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_biz.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_line.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_line.xml new file mode 100644 index 0000000000..2a1f01122d --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_line.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_line_list_item.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_line_list_item.xml new file mode 100644 index 0000000000..2be2b6f8f6 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_line_list_item.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_task.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_task.xml new file mode 100644 index 0000000000..e0f0075332 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_task.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_task_item.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_task_item.xml new file mode 100644 index 0000000000..0ea695aa8a --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_switch_task_item.xml @@ -0,0 +1,23 @@ + + + + diff --git a/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_task_running.xml b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_task_running.xml new file mode 100644 index 0000000000..86024eaf12 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/layout/shuttle_unmanned_task_running.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/raw/end_marker.nt3d b/OCH/shuttle/driver_unmanned/src/main/res/raw/end_marker.nt3d new file mode 100644 index 0000000000..be6057c547 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/raw/end_marker.nt3d differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/raw/star_marker.nt3d b/OCH/shuttle/driver_unmanned/src/main/res/raw/star_marker.nt3d new file mode 100644 index 0000000000..c6e546fc31 Binary files /dev/null and b/OCH/shuttle/driver_unmanned/src/main/res/raw/star_marker.nt3d differ diff --git a/OCH/shuttle/driver_unmanned/src/main/res/values-en/strings.xml b/OCH/shuttle/driver_unmanned/src/main/res/values-en/strings.xml new file mode 100644 index 0000000000..06ec8d1920 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/values-en/strings.xml @@ -0,0 +1,61 @@ + + Please select task + Arrived at Station + Complete + Confirm Schedule + Return + Loading... + Current vehicle has no route\nPlease contact operations personnel to bind + No task available + → %1$s + Swipe to Depart + Update Time: %1$s + + Hint + Are you sure you want to end the task? + Confirm + Cancel + + Welcome aboard Mogo Minibus + Mogo Minibus is arriving at the station + Mogo Minibus is departing + Dear passengers, the vehicle has encountered an emergency and is processing it safely. Please sit tight, follow the guidance, and thank you for your cooperation + Vehicle encountered an emergency and is processing it safely + + + + Please log out after completing task information synchronization in an area with good network + Please end the task before logging out + + No task available + Checked in %1$d people + Checked in: 0 people + + No tasks pending upload + One-click Upload + Uploading + + + + The departure time is in %1$s minutes + + Local Cache Task + → %s + No notifications + More + + + Arrived at %1$s. Please take your belongings and be aware of oncoming vehicles when getting off. + We are arriving at %1$s , get off with your belongings + %1$s 역에 도착했습니다 , 소지품 챙겨서 내리세요 + + Vehicle starting, please hold tight. The next station is %1$s. Passengers getting off please prepare. + The next station is %1$s , please get ready for your arrival + 전방에서 역에 도착하는 %1$s ,차에서 내리는 승객은 준비하세요 + + Thank you for experiencing the \'Mogo\' self-driving minibus. See you next time. + Thank you for experiencing the self-driving minibus. See you next time + 자율주행 버스를 체험해 주셔서 감사합니다. 다음에 또 뵙겠습니다 + + + diff --git a/OCH/shuttle/driver_unmanned/src/main/res/values/attrs.xml b/OCH/shuttle/driver_unmanned/src/main/res/values/attrs.xml new file mode 100644 index 0000000000..0d2c4cc409 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/values/attrs.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/values/colors.xml b/OCH/shuttle/driver_unmanned/src/main/res/values/colors.xml new file mode 100644 index 0000000000..63c1668e06 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/values/colors.xml @@ -0,0 +1,85 @@ + + + #FF1FA7FF + #FFFFFFFF + #FFFFFFFF + #FF51649D + #7F8299EB + + #51649D + #427d8e + #1FA7FF + #3FC281 + #427d8e + #3FC281 + + #80203076 + #8E9DD4 + #D4D4D4 + + #FFFFFF + #99FFFFFF + #FF52BBFF + + #BF30334C + #fff + #f1f1f1 + + #7DE261 + #FF2B2B + #E3BC59 + #FFF + #256BFF + #FFFFFF + + #DB3137 + #3E77F6 + #323C6F + + #2966EC + #F7151D41 + + #19FFFFFF + #FFFFFF + + #FFFFA28B + #FFDA1100 + #FF60FFD3 + #FF006D43 + #FFFFE198 + #FFFF9B00 + #59FFFFFF + #4D000000 + #80000000 + #B3FFFFFF + #4D2EACFF + #19E6D4 + #198BF6 + #666666 + + #CCB9C3E9 + #4Dffffff + #B3ffffff + #2EACFF + + #8E9DD4 + #2B6EFF + #00FFF8 + + #FFFFFF + #4DFFFFFF + #FFFFFF + #323C6F + #CAD6FF + #BF0E3DBC + #BF1E2E89 + #D4D4D4 + #80FFFFFF + #99FFFFFF + #4D000000 + #1970FF + · + #B3FFFFFF + #ffffffff + #80000000 + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/values/dimens.xml b/OCH/shuttle/driver_unmanned/src/main/res/values/dimens.xml new file mode 100644 index 0000000000..c45fa5d21e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/values/dimens.xml @@ -0,0 +1,164 @@ + + + + 460dp + 30dp + + 110dp + 40dp + 320dp + 20dp + 40dp + 320dp + 460dp + 70dp + 460dp + 130dp + 30dp + + #FFFFFF + #4DFFFFFF + #FFFFFF + #323C6F + 10dp + 20dp + 52dp + 65dp + 20dp + 50dp + 20dp + 38dp + 33dp + 368dp + 76dp + 60dp + 276dp + 112dp + 22dp + 36dp + 50dp + 822dp + + 46dp + 700dp + 120dp + 560dp + 116dp + 50dp + + 225dp + 154dp + 60dp + 40dp + 23dp + 210dp + 120dp + 15dp + 17dp + 154dp + 130dp + 60dp + + 27dp + + + 40dp + 32dp + 13dp + 12dp + 350dp + + 30dp + 618dp + 754dp + + 92dp + + 112dp + 112dp + + + + + + 300dp + 348dp + 211dp + 276dp + + + 220dp + 98dp + 159dp + + 32dp + 20dp + 40dp + 42dp + + 15dp + + 20dp + 36dp + 28dp + 36dp + + 3dp + 3dp + 17dp + 17dp + + + 300dp + 270dp + 30dp + 24dp + 24dp + 1dp + 30dp + 23dp + 30dp + 146dp + 20dp + 23dp + 30dp + 23dp + 26dp + 34dp + 20dp + 80dp + 3dp + 34dp + 20dp + 28dp + 27dp + + + 25.6dp + 20dp + 20dp + 64dp + 16dp + + 40dp + 40dp + 46dp + 24dp + + 530dp + 492dp + + 20dp + 20dp + 70dp + 130dp + 93dp + 150dp + 70dp + + 24dp + 616dp + 180dp + + + \ No newline at end of file diff --git a/OCH/shuttle/driver_unmanned/src/main/res/values/strings.xml b/OCH/shuttle/driver_unmanned/src/main/res/values/strings.xml new file mode 100644 index 0000000000..66cb2ec066 --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/values/strings.xml @@ -0,0 +1,61 @@ + + 请选择任务 + 到站 + 结束 + 确认班次 + 返回 + 加载中…… + 当前车辆无路线\n请联系运营人员绑定 + 暂无任务 + → %1$s + 滑动出发 + 更新时间:%1$s + + 提示 + 您确认要结束任务吗? + 确认 + 取消 + + 欢迎乘坐蘑菇小巴 + 蘑菇小巴正在进站 + 蘑菇小巴出发咯 + 尊敬的乘客,车辆遇到紧急情况,正在安全处理,请坐稳扶好,听从指引,感谢配合 + 车辆遇到紧急情况,正在安全处理 + + + + 请在网络良好的区域完成任务信息同步后退出 + 请结束任务后再退出登录 + + 暂无任务 + 核销%1$d人 + 核销:0人 + + 暂无待上传任务 + 一键上传 + 上传中 + + + + 距离发车时间还有%1$s分钟 + + 本地缓存任务 + → %s + 暂无通知 + 更多 + + + 已到达%1$s,请带好随身物品,下车时注意后方来车。 + We are arriving at %1$s ,get off with your belongings + %1$s 역에 도착했습니다 , 소지품 챙겨서 내리세요 + + 车辆起步,请扶稳坐好,前方到站是%1$s,请下车的乘客做好准备。 + The next station is %1$s ,please get ready for your arrival + 전방에서 역에 도착하는 %1$s ,차에서 내리는 승객은 준비하세요 + + 感谢您体验\'蘑菇车联\'自动驾驶小巴车,我们下次再见。 + Thank you for experiencing the self-driving minibus. See you next time + 자율주행 버스를 체험해 주셔서 감사합니다. 다음에 또 뵙겠습니다 + + + diff --git a/OCH/shuttle/driver_unmanned/src/main/res/values/style.xml b/OCH/shuttle/driver_unmanned/src/main/res/values/style.xml new file mode 100644 index 0000000000..d781ec5f1e --- /dev/null +++ b/OCH/shuttle/driver_unmanned/src/main/res/values/style.xml @@ -0,0 +1,4 @@ + + + + diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/tab/adapter/MsgBoxTabAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/tab/adapter/MsgBoxTabAdapter.kt index 5c62bac1ce..5275c41d84 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/tab/adapter/MsgBoxTabAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/tab/adapter/MsgBoxTabAdapter.kt @@ -17,13 +17,15 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.CockpitType import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp import com.mogo.eagle.core.utilcode.mogo.glide.transform.GlideRoundedCornersTransform import com.mogo.eagle.core.utilcode.util.ResourceUtils.getDrawable import com.mogo.eagle.core.utilcode.util.StringUtils import com.mogo.eagle.core.utilcode.util.TimeUtils -import com.mogo.eagle.core.utilcode.util.TimeUtils.getHourMinFormat import com.mogo.eagle.core.utilcode.util.ToastUtils +import java.text.SimpleDateFormat /** * 司机端Tab类型的消息盒子适配器 @@ -180,6 +182,9 @@ class MsgBoxTabAdapter(private val activity: Activity) : } } + private fun getHourMinFormat(): SimpleDateFormat { + return if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) TimeUtils.getHourMinSecondFormat() else TimeUtils.getHourMinFormat() + } @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { when (holder) { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/unmanned/UnmannedBoneStatusLayout.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/unmanned/UnmannedBoneStatusLayout.kt new file mode 100644 index 0000000000..8877c7c891 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/unmanned/UnmannedBoneStatusLayout.kt @@ -0,0 +1,66 @@ +package com.mogo.eagle.core.function.hmi.bone.unmanned + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.function.call.och.CallerOchCustomViewManager +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.Logger +import com.zhjt.mogo_core_function_devatools.status.StatusManager +import com.zhjt.mogo_core_function_devatools.status.entity.SpeedStatus +import com.zhjt.mogo_core_function_devatools.status.entity.Status +import kotlinx.android.synthetic.main.view_bone_top_status.view.speed_custom +import kotlinx.android.synthetic.main.view_bone_top_status.view.startAutoPilotContainer + +//无人化司机端速度状态展示 +class UnmannedBoneStatusLayout @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), StatusManager.IStatusListener { + + companion object { + const val TAG = "UnmannedRightBottomStatusLayout" + } + + init { + LayoutInflater.from(context).inflate(R.layout.view_unmanned_bone_status, this, true) + addStartAutoPilotView() + } + + private fun addStartAutoPilotView() { + if (context == null) { + CallerLogger.e(TAG, "addStartAutoPilotView context==null") + return + } + kotlin.runCatching { + startAutoPilotContainer?.also { container -> + container.removeAllViews() + val view = CallerOchCustomViewManager.getStartAutopilotView(context) + Logger.d(TAG, "$view ${Thread.currentThread().name}") + view?.also { + container.addView(it) + } + } + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + StatusManager.addListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + StatusManager.removeListener(TAG) + } + + override fun onStatusChanged(changed: List, all: List) { + changed.find { it is SpeedStatus }?.also { + val speed = it as SpeedStatus + speed_custom?.updateSpeed(speed.speed) + } + } + + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/unmanned/UnmannedToolStopServiceView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/unmanned/UnmannedToolStopServiceView.kt new file mode 100644 index 0000000000..bd0dc7ac8d --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/bone/unmanned/UnmannedToolStopServiceView.kt @@ -0,0 +1,442 @@ +package com.mogo.eagle.core.function.hmi.bone.unmanned + +import android.animation.ObjectAnimator +import android.animation.ValueAnimator +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import android.view.animation.LinearInterpolator +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.ContextCompat +import com.mogo.commons.voice.AIAssist +import com.mogo.eagle.core.data.app.AppConfigInfo +import com.mogo.eagle.core.data.enums.EventTypeEnumNew +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.data.msgbox.MsgBoxType +import com.mogo.eagle.core.data.msgbox.V2XMsg +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoReceiveReceivedAckListener +import com.mogo.eagle.core.function.api.devatools.IPowerOffListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerReceiveReceivedAckListenerManager +import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager +import com.mogo.eagle.core.function.call.devatools.CallerPowerOffManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox +import com.mogo.eagle.core.function.hmi.R +import com.mogo.eagle.core.function.hmi.ui.utils.HmiActionLog.Companion.hmiAction +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI +import com.mogo.eagle.core.utilcode.util.ParseVersionUtils +import com.mogo.eagle.core.utilcode.util.StringUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.zhjt.mogo.adas.common.MessageType +import com.zhjt.mogo.adas.data.AdasConstants +import com.zhjt.mogo.adas.data.bean.ReceivedAck +import kotlinx.android.synthetic.main.unmanned_view_tool_stop_service.view.tvCheckShutDown +import kotlinx.android.synthetic.main.unmanned_view_tool_stop_service.view.tvCountDown +import kotlinx.android.synthetic.main.unmanned_view_tool_stop_service.view.tvCountDownUnit +import kotlinx.android.synthetic.main.unmanned_view_tool_stop_service.view.viewCheckShutDown +import kotlinx.android.synthetic.main.unmanned_view_tool_stop_service.view.viewProgress +import kotlinx.android.synthetic.main.unmanned_view_tool_stop_service.view.viewProgressBackground + + +/** + * 一件停服 + */ +class UnmannedToolStopServiceView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotStatusListener, + IPowerOffListener, IMoGoReceiveReceivedAckListener { + + companion object { + const val TAG = "UnmannedToolStopServiceView" + } + + //重启系统对话框 + private var connectStatus: Boolean = false //与工控机的连接状态 + private var isExecutingPowerOff: Boolean = false //是否正在下发一键停服命令 + private var isPowerOffCountDown: Boolean = false //一键停服是否处于1分钟倒计时 + private var powerOffMsgId: Long = -1 //一键停服命令下发Id + private var progressAnimator: ObjectAnimator? = null //一键停服命令倒计时 + + /** + * 停止域控服务状态 + * 0:准备停服 1:停服命令下发中 2:停服命令下发成功 3:停服命令下发失败 + * 4:停服命令下发超时 5:停服中 6:停服成功 7:停服成功不可点击 + */ + private var powerOffStatus: Int = 0 + + init { + LayoutInflater.from(context).inflate(R.layout.unmanned_view_tool_stop_service, this, true) + initView() + } + + private fun initView() { + //一键停服 + viewCheckShutDown.setOnClickListener { + powerOff() + } + tvCheckShutDown.setOnClickListener { + powerOff() + } + CallerDevaToolsManager.getPowerOffStatus()?.let { + powerOffStatus = it + } + when (powerOffStatus) { + //准备停服 + 0 -> { + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service + ) + ) + viewCheckShutDown.isClickable = true + } + //停服命令下发中 + 1 -> { + isExecutingPowerOff = true + } + //停服命令下发成功 + 2 -> { + viewProgressBackground.visibility = View.VISIBLE + viewProgress.visibility = View.VISIBLE + tvCountDown.visibility = View.VISIBLE + tvCountDownUnit.visibility = View.VISIBLE + //开始旋转动画 + if (progressAnimator == null) { + progressAnimator = ObjectAnimator.ofFloat(viewProgress, "rotation", 0f, 360f) + } + progressAnimator?.interpolator = LinearInterpolator() + progressAnimator?.repeatCount = ValueAnimator.INFINITE //无限循环 + progressAnimator?.duration = 10000 //设置持续时间 + progressAnimator?.startDelay = 0 + progressAnimator?.start() + //一键停服倒计时中 + isPowerOffCountDown = true + } + //停服命令下发失败 + 3 -> { + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_fail + ) + ) + } + //停服命令下发超时 + 4 -> { + //将图标改为失败 + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_fail + ) + ) + } + //停服中 + 5 -> { + isPowerOffCountDown = true + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_background + ) + ) + viewProgressBackground.visibility = View.VISIBLE + viewProgress.visibility = View.VISIBLE + tvCountDown.visibility = View.VISIBLE + tvCountDownUnit.visibility = View.VISIBLE + //开始旋转动画 + if (progressAnimator == null) { + progressAnimator = ObjectAnimator.ofFloat(viewProgress, "rotation", 0f, 360f) + } + progressAnimator?.interpolator = LinearInterpolator() + progressAnimator?.repeatCount = ValueAnimator.INFINITE //无限循环 + progressAnimator?.duration = 10000 //设置持续时间 + progressAnimator?.startDelay = 0 + progressAnimator?.start() + } + //停服成功 + 6 -> { + //停止一键停服进度属性动画 + progressAnimator?.cancel() + //隐藏一键停服进度视图 + viewProgressBackground.visibility = View.GONE + viewProgress.visibility = View.GONE + tvCountDown.visibility = View.GONE + tvCountDownUnit.visibility = View.GONE + //一键停服命令倒计时结束,变为成功状态,并且发送1s倒计时 + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_success + ) + ) + isPowerOffCountDown = false + } + //停服成功不可点击 + 7 -> { + //将倒计时内容隐藏 + viewProgressBackground.visibility = View.GONE + viewProgress.visibility = View.GONE + tvCountDown.visibility = View.GONE + tvCountDownUnit.visibility = View.GONE + //停服成功,将按钮置为不可点击状态 + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_complete + ) + ) + viewCheckShutDown.isClickable = false + isPowerOffCountDown = false + } + } + } + + /** + * 一键停服 + */ + private fun powerOff() { + if (!connectStatus) { +// ToastUtils.showShort("尚未连接工控机,无法下发一键停服命令") + ToastUtils.showShort(R.string.module_mogo_core_function_hmi_not_sent_shutdown_ipc) + return + } + if (AppConfigInfo.dockerVersion.isEmpty()) { +// ToastUtils.showShort("尚未连接工控机,无法下发一键停服命令") + ToastUtils.showShort(R.string.module_mogo_core_function_hmi_not_sent_shutdown_ipc) + return + } + if (ParseVersionUtils.parseVersion(true, AppConfigInfo.dockerVersion) < 40100) { +// ToastUtils.showShort("此域控版本不支持一键停服功能,最低支持版本为4.1.0") + ToastUtils.showShort(R.string.module_mogo_core_function_hmi_ipc_version_nonsupport_shutdown_ipc) + return + } + if (CallerAutoPilotStatusListenerManager.getState() == 2) { + //当前处于自动驾驶状态,不可进行重启,Toast提示 +// ToastUtils.showShort("请先退出自动驾驶状态") + ToastUtils.showShort(R.string.module_mogo_core_function_hmi_please_exit_autopilot_state) + return + } + if (isExecutingPowerOff) { + //一键停服命令下发执行中 +// ToastUtils.showShort("一键停服命令下发中,请勿重复点击") + ToastUtils.showShort(R.string.module_mogo_core_function_hmi_sending_shutdown_ipc) + return + } + if (isPowerOffCountDown) { + //系统停服中 +// ToastUtils.showShort("系统停服中,请勿重复点击") + ToastUtils.showShort(R.string.module_mogo_core_function_hmi_shutdowning_ipc) + return + } + //将是否正在下发一键停服命令标签改为true + isExecutingPowerOff = true + CallerDevaToolsManager.setPowerOffStatus(1) + hmiAction("$M_HMI$TAG", mapOf("powerOff" to true)) + //系统命令请求 关机 + powerOffMsgId = CallerAutoPilotControlManager.sendIpcPowerOff() + hmiAction("$M_HMI$TAG", mapOf("powerOffID" to powerOffMsgId)) + //开始执行10秒等待倒计时 + CallerDevaToolsManager.startCommandWaitCountDown() + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerAutoPilotStatusListenerManager.addListener(TAG, this) + CallerPowerOffManager.addListener(TAG, this) + CallerReceiveReceivedAckListenerManager.addListener(TAG, this) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerAutoPilotStatusListenerManager.removeListener(TAG) + CallerPowerOffManager.removeListener(TAG) + CallerReceiveReceivedAckListenerManager.removeListener(TAG) + } + + override fun onAutopilotIpcConnectStatusChanged( + status: AdasConstants.IpcConnectionStatus, + reason: String? + ) { + super.onAutopilotIpcConnectStatusChanged(status, reason) + ThreadUtils.runOnUiThread { + setViewStatus(status == AdasConstants.IpcConnectionStatus.CONNECTED) + } + } + + private fun setViewStatus(connectInfo: Boolean) { + connectStatus = connectInfo + //下发一键停服命令后又和域控重新连接 + if ((powerOffStatus == 6 || powerOffStatus == 7) && connectStatus) { + CallerDevaToolsManager.setPowerOffStatus(0) + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service + ) + ) + viewCheckShutDown.isClickable = true + } + } + + /** + * 一键停服调用SSM停服命令超时 + */ + override fun commandTimeout() { + //停止命令超时倒计时 + CallerDevaToolsManager.stopCommandWaitCountDown() + /** + * 如果点击一键停服按钮10秒后,是否正在执行命令的标签仍为true,代表域控未返回执行结果 + * 此时应该将按钮状态短暂置为失败,之后再置为常态,并将此标签置为false + */ + if (isExecutingPowerOff) { + //更改标签状态 + isExecutingPowerOff = false + CallerDevaToolsManager.setPowerOffStatus(4) + //将图标改为失败 + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_fail + ) + ) + //执行1秒倒计时命令 + CallerDevaToolsManager.statusChangeCountDown(false) + } + } + + /** + * 一键停服车辆下电等待倒计时 + */ + override fun powerDownTick(second: Int) { + tvCountDown.text = second.toString() + CallerDevaToolsManager.setPowerOffStatus(5) + } + + /** + * 一键停服车辆下电等待倒计时结束 + */ + override fun powerDownFinish() { + CallerDevaToolsManager.setPowerOffStatus(6) + //停止一键停服进度属性动画 + progressAnimator?.cancel() + //隐藏一键停服进度视图 + viewProgressBackground.visibility = View.GONE + viewProgress.visibility = View.GONE + tvCountDown.visibility = View.GONE + tvCountDownUnit.visibility = View.GONE + //一键停服命令倒计时结束,变为成功状态,并且发送1s倒计时 + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_success + ) + ) + isPowerOffCountDown = false + //执行1秒倒计时命令 + CallerDevaToolsManager.statusChangeCountDown(true) + } + + /** + * 一键停服状态按钮变更通知 + */ + override fun statusChange(isSuccess: Boolean) { + CallerDevaToolsManager.stopStatusCountDown() + if (isSuccess) { + //将倒计时内容隐藏 + viewProgressBackground.visibility = View.GONE + viewProgress.visibility = View.GONE + tvCountDown.visibility = View.GONE + tvCountDownUnit.visibility = View.GONE + //停服成功,将按钮置为不可点击状态 + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_complete + ) + ) + viewCheckShutDown.isClickable = false + CallerDevaToolsManager.setPowerOffStatus(7) + } else { + //停服命令下发失败,将按钮置为常态,可点击 + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service + ) + ) + viewCheckShutDown.isClickable = true + } + } + + /** + * 命令下发回执 + */ + override fun onReceiveReceivedAck(receivedAck: ReceivedAck) { + ThreadUtils.runOnUiThread { + if (receivedAck.messageType == MessageType.TYPE_SEND_SYSTEM_CMD_REQ && receivedAck.msgId == powerOffMsgId) { + isExecutingPowerOff = false + //停止命令超时倒计时 + CallerDevaToolsManager.stopCommandWaitCountDown() + if (receivedAck.status == ReceivedAck.Status.NORMAL) { + //一键停服命令回执成功,则正常进入停服阶段中,1分钟倒计时,并且TTS和消息盒子提示 + CallerDevaToolsManager.setPowerOffStatus(2) +// AIAssist.getInstance(context).speakTTSVoice("请等待1分钟再执行车辆下电") + AIAssist.getInstance(context).speakTTSVoice(StringUtils.getString(R.string.module_core_one_minute_later_power_off)) + saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, V2XMsg( + EventTypeEnumNew.TYPE_POWER_OFF_TIP.poiType, + EventTypeEnumNew.TYPE_POWER_OFF_TIP.content, + EventTypeEnumNew.TYPE_POWER_OFF_TIP.tts + ) + ) + ) + + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_background + ) + ) + viewProgressBackground.visibility = View.VISIBLE + viewProgress.visibility = View.VISIBLE + tvCountDown.visibility = View.VISIBLE + tvCountDownUnit.visibility = View.VISIBLE + //开始旋转动画 + if (progressAnimator == null) { + progressAnimator = + ObjectAnimator.ofFloat(viewProgress, "rotation", 0f, 360f) + } + progressAnimator?.interpolator = LinearInterpolator() + progressAnimator?.repeatCount = ValueAnimator.INFINITE //无限循环 + progressAnimator?.duration = 2500 //设置持续时间 + progressAnimator?.startDelay = 0 + progressAnimator?.start() + //开始60S倒计时 + CallerDevaToolsManager.startPowerDownCountDown() + //一键停服倒计时中 + isPowerOffCountDown = true + } else { + //一键停服命令回执失败,则走失败流程 + CallerDevaToolsManager.setPowerOffStatus(3) + viewCheckShutDown.setImageDrawable( + ContextCompat.getDrawable( + context, + R.drawable.icon_toolkit_item_stop_service_fail + ) + ) + //执行1秒倒计时命令 + CallerDevaToolsManager.statusChangeCountDown(false) + } + } + } + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 739d5c1257..566b2fe3cf 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -97,6 +97,7 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager import com.mogo.eagle.core.function.call.obu.CallerObuApiManager import com.mogo.eagle.core.function.call.obu.CallerObuConnectListenerManager import com.mogo.eagle.core.function.call.obu.CallerObuInfoListenerManager +import com.mogo.eagle.core.function.call.och.CallerOchBizFunctionCall4EagleManager import com.mogo.eagle.core.function.call.setting.CallerMapShowNameManager import com.mogo.eagle.core.function.call.setting.CallerMoGoUiSettingManager import com.mogo.eagle.core.function.call.setting.CallerSopSettingManager @@ -110,6 +111,7 @@ import com.mogo.eagle.core.utilcode.kotlin.lifecycleOwner import com.mogo.eagle.core.utilcode.kotlin.onClick import com.mogo.eagle.core.utilcode.kotlin.scope import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.CockpitType import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.LogLevel import com.mogo.eagle.core.utilcode.mogo.logger.Logger @@ -262,6 +264,7 @@ import kotlinx.android.synthetic.main.view_debug_setting.view.tbIsStrictMode import kotlinx.android.synthetic.main.view_debug_setting.view.tbLanguage import kotlinx.android.synthetic.main.view_debug_setting.view.tbLogCatch import kotlinx.android.synthetic.main.view_debug_setting.view.tbLogcatCenter +import kotlinx.android.synthetic.main.view_debug_setting.view.tbLoginLogout import kotlinx.android.synthetic.main.view_debug_setting.view.tbNetLog import kotlinx.android.synthetic.main.view_debug_setting.view.tbObuController import kotlinx.android.synthetic.main.view_debug_setting.view.tbObuLog @@ -882,6 +885,22 @@ internal class DebugSettingView @JvmOverloads constructor( else -> {} } + + if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) { + tbLoginLogout.visibility = if (CallerOchBizFunctionCall4EagleManager.isLogin()) View.VISIBLE else View.GONE + } else { + tbLoginLogout.visibility = View.GONE + } + + //退出登录 + tbLoginLogout.setOnCheckedChangeListener { buttonView, isChecked -> + if (CallerOchBizFunctionCall4EagleManager.isLogin()) { + CallerOchBizFunctionCall4EagleManager.logout() + } else { + ToastUtils.showShort("无法退出,状态获取错误") + } + } + /** * 语言 */ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ColdStartAgainWindow.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ColdStartAgainWindow.kt index 76a17d0285..05554e3395 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ColdStartAgainWindow.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ColdStartAgainWindow.kt @@ -1,5 +1,8 @@ package com.mogo.eagle.core.function.hmi.ui.widget +import android.animation.Animator +import android.animation.AnimatorSet +import android.animation.ObjectAnimator import android.app.Activity import android.graphics.PixelFormat import android.util.DisplayMetrics @@ -7,15 +10,21 @@ import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.view.WindowManager +import android.view.animation.DecelerateInterpolator +import android.view.animation.LinearInterpolator import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.commons.AbsMogoApplication import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.CockpitType +import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.mogo.eagle.core.widget.media.video.SkinSimpleVideoPlayer import com.mogo.skin.utils.SkinResources import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack import com.zhjt.mogo_core_function_devatools.coldstart.ColdStartConfig +import me.jessyan.autosize.utils.AutoSizeUtils /** * 打开app后首次与域控链接或与域控断连1min后,需要回到界面并呈现一遍流程 @@ -30,6 +39,9 @@ class ColdStartAgainWindow constructor(activity: Activity){ private lateinit var clColdStartAgain: ConstraintLayout private lateinit var svpColdStart: SkinSimpleVideoPlayer private lateinit var coldStart: ColdStartView + private lateinit var cl_welcome_info: View + private var showLoginInfoAnimator11: ObjectAnimator? = null + private var showLoginInfoAnimator22: ObjectAnimator? = null private val gsyVideoOptionBuilder = GSYVideoOptionBuilder() @@ -42,6 +54,7 @@ class ColdStartAgainWindow constructor(activity: Activity){ clColdStartAgain = mFloatLayout.findViewById(R.id.cl_cold_start_again) svpColdStart = mFloatLayout.findViewById(R.id.svp_cold_start) coldStart = mFloatLayout.findViewById(R.id.view_cold_start_again) + cl_welcome_info = mFloatLayout.findViewById(R.id.cl_welcome_info) val videoUrl:String = if (AppIdentityModeUtils.isT1T2(FunctionBuildConfig.appIdentityMode)) { svpColdStart.setBackgroundResource(R.drawable.biz_login_bg_taxi_start) @@ -67,6 +80,46 @@ class ColdStartAgainWindow constructor(activity: Activity){ .setPlayTag("TaxiPassengerArrivedView") .build(svpColdStart) + if (AppIdentityModeUtils.getCockpitType() == CockpitType.UNMANNED) { + if (showLoginInfoAnimator11 == null) { + showLoginInfoAnimator11 = ObjectAnimator.ofFloat(cl_welcome_info, "alpha", 0f, 1f) + showLoginInfoAnimator11?.interpolator = LinearInterpolator() + } + if (showLoginInfoAnimator22 == null) { + val dp2px = AutoSizeUtils.dp2px(AbsMogoApplication.getApp(), -50f) + showLoginInfoAnimator22 = ObjectAnimator.ofFloat(cl_welcome_info, "translationY", 0f, dp2px.toFloat()) + showLoginInfoAnimator22?.interpolator = DecelerateInterpolator() + } + UiThreadHandler.postDelayed({ + cl_welcome_info.let { + val animatorSet = AnimatorSet() + animatorSet.playTogether(showLoginInfoAnimator11, showLoginInfoAnimator22) + animatorSet.duration = 500 + animatorSet.addListener(object : Animator.AnimatorListener { + override fun onAnimationStart(animation: Animator) { + cl_welcome_info.visibility = View.VISIBLE + } + + override fun onAnimationEnd(animation: Animator) { + + } + + override fun onAnimationCancel(animation: Animator) { + + } + + override fun onAnimationRepeat(animation: Animator) { + + } + + }) + animatorSet.start() + } + }, 1_000, UiThreadHandler.MODE.QUEUE) + } else { + cl_welcome_info.visibility = View.GONE + } + svpColdStart.setVideoAllCallBack(object : GSYSampleCallBack() { override fun onAutoComplete(url: String?, vararg objects: Any?) { if (AppIdentityModeUtils.isT1T2(FunctionBuildConfig.appIdentityMode)) { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarUnmannedView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarUnmannedView.kt index 03efca49df..f98d50f773 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarUnmannedView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/StatusBarUnmannedView.kt @@ -14,6 +14,9 @@ import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.util.ThreadUtils import kotlinx.android.synthetic.main.view_status_bar_unmanned.view.viewTextClock +/** + * 无人化状司机屏态栏 + */ class StatusBarUnmannedView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, @@ -26,7 +29,7 @@ class StatusBarUnmannedView @JvmOverloads constructor( init { LayoutInflater.from(context).inflate(R.layout.view_status_bar_unmanned, this, true) - background = ColorDrawable(Color.parseColor("#A6000000")) // 黑色的65% + background = ColorDrawable(Color.parseColor("#00222222")) } override fun onAttachedToWindow() { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-nodpi/biz_login_robobus.webp b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-nodpi/biz_login_robobus.webp new file mode 100644 index 0000000000..79873bbf44 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-nodpi/biz_login_robobus.webp differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-nodpi/unmanned_bone_status_bg.webp b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-nodpi/unmanned_bone_status_bg.webp new file mode 100644 index 0000000000..72e7d16326 Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-nodpi/unmanned_bone_status_bg.webp differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/unmanned_view_tool_stop_service.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/unmanned_view_tool_stop_service.xml new file mode 100644 index 0000000000..37f1b990f1 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/unmanned_view_tool_stop_service.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml index da39c97ca9..e78d5fc6e6 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml @@ -233,6 +233,18 @@ android:layout_height="1dp" android:background="#F0F0F0" /> + + + android:textSize="@dimen/dp_24" + android:visibility="gone" /> @@ -29,7 +30,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_marginStart="@dimen/dp_30" /> + android:layout_marginStart="@dimen/dp_20" + app:wifi_show_title="true" /> - - - - + android:layout_gravity="center" + android:layout_marginEnd="@dimen/dp_40" /> + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/window_cold_start_again.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/window_cold_start_again.xml index 5aff769366..bde92d9687 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/window_cold_start_again.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/window_cold_start_again.xml @@ -14,6 +14,31 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + + + + Selected Date Unavailable Traffic Light Background - + Welcome on diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml index c021b0a3bd..643369ced4 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/values/strings.xml @@ -303,5 +303,5 @@ 所选日期无法拷贝 红绿灯灯态背景 - + 欢迎乘坐 diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/och/IOchBizFunctionCall4Eagle.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/och/IOchBizFunctionCall4Eagle.kt index b4a8876709..27d1114c20 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/och/IOchBizFunctionCall4Eagle.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/och/IOchBizFunctionCall4Eagle.kt @@ -10,5 +10,8 @@ interface IOchBizFunctionCall4Eagle { * 退出登录 */ fun logout() + + fun isLogin(): Boolean + fun setVideoView(target: View?) } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/och/CallerOchBizFunctionCall4EagleManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/och/CallerOchBizFunctionCall4EagleManager.kt index 1ccc6ca424..4c589dd093 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/och/CallerOchBizFunctionCall4EagleManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/och/CallerOchBizFunctionCall4EagleManager.kt @@ -26,6 +26,10 @@ object CallerOchBizFunctionCall4EagleManager : IOchBizFunctionCall4Eagle { ochBizFunctionCall4EagleInstance?.logout() } + override fun isLogin(): Boolean { + return ochBizFunctionCall4EagleInstance?.isLogin() == true + } + override fun setVideoView(target: View?) { ochBizFunctionCall4EagleInstance?.setVideoView(target) } diff --git a/core/mogo-core-res/src/main/res/values-en/string.xml b/core/mogo-core-res/src/main/res/values-en/string.xml index 6b34efd475..889a7ac278 100644 --- a/core/mogo-core-res/src/main/res/values-en/string.xml +++ b/core/mogo-core-res/src/main/res/values-en/string.xml @@ -259,7 +259,7 @@ Long-connection error, please enable permissions or check network Location service error Network error - %s please enable permissions or check network + , Enable relevant permission, check system location service or network connection. Please wait to wake up Network error, please retry Enable in-vehicle location and retry diff --git a/core/mogo-core-res/src/main/res/values/string.xml b/core/mogo-core-res/src/main/res/values/string.xml index 6a7accb596..ea0270f7a1 100644 --- a/core/mogo-core-res/src/main/res/values/string.xml +++ b/core/mogo-core-res/src/main/res/values/string.xml @@ -259,7 +259,7 @@ 长链接异常,请开启相应权限或者查看网络 定位服务异常 网络异常 - %s请开启相应权限或者查看网络 + ,请开启相应权限或检查系统定位服务是否开启或者查看网络 请稍后唤醒 网络异常,请重试 请开启车机定位后重试 diff --git a/settings.gradle b/settings.gradle index 5f917d759f..8ce56ea44c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -88,6 +88,7 @@ include ':OCH:charter:passenger' include ':OCH:shuttle:driver_weaknet' +include ':OCH:shuttle:driver_unmanned' include ':OCH:shuttle:passenger_weaknet' include ':OCH:offline:driver'