[6.6.0]数据闭环

This commit is contained in:
xuxinchao
2024-08-22 19:38:08 +08:00
parent 58cf773b1e
commit af7a388b84
16 changed files with 209 additions and 59 deletions

View File

@@ -1,6 +1,7 @@
package com.zhjt.mogo_core_function_devatools.badcase
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
@@ -74,6 +75,8 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
private var record: AutoPilotRecord? = null
private var recordKey: Long = 0 //主动录制bag包key
@SuppressLint("StaticFieldLeak")
private var reportTypeWindow: ReportTypeWindow ?= null
fun init(context: Context) {
CallerAutopilotRecordListenerManager.addListener(TAG, this)
@@ -191,18 +194,19 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
view.setOnClickListener{
if (ClickUtils.isFastClick()){
if (NetworkUtils.isConnected()){
//TODO 更改dockerVersion是否为空
if (BadCaseConfig.dockerVersion == null){
if (BadCaseConfig.dockerVersion != null){
if(ProjectUtils.isSaas()){
//660版本数据闭环增加统一上报问题入口仅限于saas渠道
//TODO 已存在WIndow再次点击会再次创建WIndow
val reportTypeWindow = ReportTypeWindow(activity)
reportTypeWindow.setClickListener(object: ReportTypeWindow.ClickListener{
override fun closeWindow() {
reportTypeWindow.hideFloatWindow()
}
})
reportTypeWindow.showFloatWindow()
if(reportTypeWindow == null){
reportTypeWindow = ReportTypeWindow(activity)
reportTypeWindow?.setClickListener(object: ReportTypeWindow.ClickListener{
override fun closeWindow() {
reportTypeWindow?.hideFloatWindow()
reportTypeWindow = null
}
})
reportTypeWindow?.showFloatWindow()
}
}else{
//展示工单上报弹窗
val workOrderWindow = WorkOrderWindow(activity)

View File

@@ -5,6 +5,8 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.graphics.PixelFormat
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.Editable
import android.text.TextWatcher
import android.util.DisplayMetrics
@@ -27,28 +29,44 @@ import androidx.constraintlayout.widget.Group
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.amap.api.services.core.LatLonPoint
import com.amap.api.services.geocoder.GeocodeResult
import com.amap.api.services.geocoder.GeocodeSearch
import com.amap.api.services.geocoder.RegeocodeQuery
import com.amap.api.services.geocoder.RegeocodeResult
import com.iflytek.cloud.ErrorCode
import com.iflytek.cloud.InitListener
import com.iflytek.cloud.RecognizerListener
import com.iflytek.cloud.RecognizerResult
import com.iflytek.cloud.SpeechError
import com.iflytek.cloud.SpeechRecognizer
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.deva.report.CategoryInfo
import com.mogo.eagle.core.data.deva.report.PadAddProblemReq
import com.mogo.eagle.core.data.deva.report.PadProblemInfo
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
import com.mogo.eagle.core.function.api.order.IOrderListener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.order.CallerOrderListenerManager
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.JsonParser
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils.millis2String
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.tts.base.SpeechUtils
import com.zhjt.mogo_core_function_devatools.R
import com.zhjt.mogo_core_function_devatools.workorder.adapter.OrderReasonAdapter
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlin.math.absoluteValue
/**
* 故障原因编辑窗口
*/
class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener,
IMoGoDevaToolsListener, IOrderListener {
companion object{
const val TAG = "FaultReasonWindow"
@@ -93,6 +111,15 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
private lateinit var orderReasonAdapter: OrderReasonAdapter
private var address: String = "" //故障地点
private var faultCodeList = ArrayList<String>() //故障码列表
private var level1Id: Int = 0 //一级分类ID
private var level2Id: Int = 0 //二级分类ID
private var level3Id: Int = 0 //三级分类ID
private var lineName: String = "" //行驶路线
private var reportNote: String = "" //上报描述
private val reportType: Int = 2 //上报方式0小程序 1司机屏 2云端上报
init {
initFloatWindow()
}
@@ -158,6 +185,8 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
@SuppressLint("SetTextI18n")
private fun initEvent(){
CallerDevaToolsListenerManager.addListener(TAG, this)
CallerOrderListenerManager.addListener(TAG,this)
val iconDown = ContextCompat.getDrawable(mActivity, R.drawable.icon_fault_expand)
iconDown?.setBounds(0, 0, iconDown.minimumWidth, iconDown.minimumHeight)
val iconUp = ContextCompat.getDrawable(mActivity, R.drawable.icon_fault_retract)
@@ -268,7 +297,30 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
}
//上报
tvFaultReport.setOnClickListener{
//TODO
CallerOrderListenerManager.invokeOrderLineUpdate("测试")
val geocodeSearch = GeocodeSearch(mActivity)
geocodeSearch.setOnGeocodeSearchListener(object: GeocodeSearch.OnGeocodeSearchListener {
override fun onRegeocodeSearched(regeocodeResult: RegeocodeResult?, p1: Int) {
regeocodeResult?.regeocodeAddress?.formatAddress?.let {
address = it
}
val padProblemList= ArrayList<PadProblemInfo>()
val padProblemInfo = PadProblemInfo(address,faultCodeList,millis2String(workOrderOccurrenceTime),level1Id,
level2Id,level3Id,lineName,reportNote,reportType,
SharedPrefsMgr.getInstance().getString("och_account",""))
padProblemList.add(padProblemInfo)
val padAddProblemReq = PadAddProblemReq(padProblemList,AppConfigInfo.plateNumber)
CallerDevaToolsManager.problemPadAdd(padAddProblemReq)
}
override fun onGeocodeSearched(p0: GeocodeResult?, p1: Int) {
}
})
val latLon = LatLonPoint(CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude, CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude)
val q = RegeocodeQuery(latLon,200f,GeocodeSearch.AMAP)
geocodeSearch.getFromLocationAsyn(q)
}
//取消
tvFaultCancel.setOnClickListener {
@@ -306,6 +358,10 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
}
}
/**
* 初始化监听器。
*/
/**
* 初始化监听器。
*/
@@ -315,6 +371,10 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
}
}
/**
* 听写监听器。
*/
/**
* 听写监听器。
*/
@@ -353,6 +413,10 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
}
/**
* 显示结果
*/
/**
* 显示结果
*/
@@ -416,10 +480,11 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
}
fun hideFloatWindow() {
CallerDevaToolsListenerManager.removeListener(TAG)
CallerOrderListenerManager.removeListener(TAG)
if (mFloatLayout.parent != null){
mWindowManager!!.removeView(mFloatLayout)
}
CallerDevaToolsListenerManager.removeListener(TAG)
}
fun setClickListener(clickListener: ClickListener) {
@@ -430,4 +495,42 @@ class FaultReasonWindow constructor(activity: Activity) : View.OnTouchListener{
fun closeWindow()
}
/**
* 故障上报成功
*/
override fun problemPadAddSuccess() {
super.problemPadAddSuccess()
//显示上报成功页面,短暂停留关闭弹窗
ThreadUtils.runOnUiThread {
rvFaultList.visibility = View.GONE
tvUploadSuccess.visibility = View.VISIBLE
faultReasonGroup.visibility = View.GONE
val successHandler = Handler(Looper.getMainLooper())
successHandler.postDelayed({
hideFloatWindow()
},1500)
}
}
override fun problemPadAddError(msg: String) {
super.problemPadAddError(msg)
ToastUtils.showShort("故障原因上报失败$msg")
}
override fun getCategoriesSuccess(list: List<CategoryInfo>) {
super.getCategoriesSuccess(list)
}
override fun getCategoriesError(msg: String) {
super.getCategoriesError(msg)
}
/**
* 订单路线名称变化监听
* @param lineName 路线名称
*/
override fun onOrderLineUpdate(lineName: String) {
this.lineName = lineName
}
}

View File

@@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.graphics.PixelFormat
import android.os.CountDownTimer
import android.os.Handler
import android.os.Looper
import android.os.SystemClock
import android.util.DisplayMetrics
import android.view.Gravity
@@ -125,11 +127,17 @@ class ReportTypeWindow constructor(activity: Activity) {
BadCaseConfig.type, Random(SystemClock.elapsedRealtime()).nextInt().absoluteValue,
BadCaseConfig.totalDuration, BadCaseConfig.previousDuration)
if(response){
ToastUtils.showShort("主动录包命令下发成功")
//已发起录包
reportTypeGroup.visibility = View.GONE
tvReportSuccess.visibility = View.VISIBLE
tvReportSuccess.text = mActivity.resources.getString(R.string.record_success)
val successHandler = Handler(Looper.getMainLooper())
successHandler.postDelayed({
clickListener?.closeWindow()
},1500)
}else{
ToastUtils.showShort("主动录包命令下发失败")
}
clickListener?.closeWindow()
}
}
@@ -139,7 +147,7 @@ class ReportTypeWindow constructor(activity: Activity) {
val metrics = DisplayMetrics()
// 默认固定位置,靠屏幕右边缘的中间
mWindowManager!!.defaultDisplay.getMetrics(metrics)
mWindowParams!!.x = metrics.widthPixels-2257
mWindowParams!!.x = metrics.widthPixels-2258
mWindowParams!!.y = metrics.heightPixels - BarUtils.getStatusBarHeight()-420
mWindowManager!!.addView(mFloatLayout, mWindowParams)
}

View File

@@ -33,6 +33,8 @@ import com.iflytek.cloud.RecognizerListener
import com.iflytek.cloud.RecognizerResult
import com.iflytek.cloud.SpeechError
import com.iflytek.cloud.SpeechRecognizer
import com.mogo.eagle.core.data.deva.report.CategoryInfo
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.JsonParser
@@ -48,7 +50,8 @@ import kotlin.math.absoluteValue
/**
* 接管原因编辑窗口
*/
class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListener {
class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListener,
IMoGoDevaToolsListener {
companion object{
const val TAG = "TakeOverReasonWindow"
@@ -150,6 +153,7 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene
@SuppressLint("SetTextI18n")
private fun initEvent(){
CallerDevaToolsListenerManager.addListener(TAG, this)
val iconDown = ContextCompat.getDrawable(mActivity, R.drawable.icon_fault_expand)
iconDown?.setBounds(0, 0, iconDown.minimumWidth, iconDown.minimumHeight)
val iconUp = ContextCompat.getDrawable(mActivity, R.drawable.icon_fault_retract)
@@ -246,7 +250,8 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene
}
//上报
tvTakeOverReport.setOnClickListener{
//TODO
//TODO 保存到数据库‘
hideFloatWindow()
}
//取消
tvTakeOverCancel.setOnClickListener {
@@ -407,4 +412,12 @@ class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListene
fun closeWindow()
}
override fun getCategoriesSuccess(list: List<CategoryInfo>) {
super.getCategoriesSuccess(list)
}
override fun getCategoriesError(msg: String) {
super.getCategoriesError(msg)
}
}

View File

@@ -4,19 +4,25 @@ import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.mogo.eagle.core.data.deva.report.TakeOverRecordInfo
import com.mogo.eagle.core.function.call.takeover.CallerTakeOverManager
import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils.getYMDFormat
import com.mogo.eagle.core.utilcode.util.Utils
import com.zhjt.mogo_core_function_devatools.R
import com.zhjt.mogo_core_function_devatools.workorder.adapter.BottomDecoration
import com.zhjt.mogo_core_function_devatools.workorder.adapter.TakeOverListAdapter
import kotlinx.android.synthetic.main.view_take_over_record.view.ivTakeOverRecordClose
import kotlinx.android.synthetic.main.view_take_over_record.view.recordGroup
import kotlinx.android.synthetic.main.view_take_over_record.view.rvTakeOverList
import kotlinx.android.synthetic.main.view_take_over_record.view.tvDeleteSelect
import kotlinx.android.synthetic.main.view_take_over_record.view.tvRecordNoData
import kotlinx.android.synthetic.main.view_take_over_record.view.tvTakeOverRecordDate
import kotlinx.android.synthetic.main.view_take_over_record.view.tvUpload
import kotlinx.coroutines.Dispatchers
@@ -37,6 +43,10 @@ class TakeOverRecordView @JvmOverloads constructor(
const val TAG = "TakeOverRecordView"
}
private val scope by lazy {
Utils.getApp().lifeCycleScope
}
private var takeOverListAdapter: TakeOverListAdapter ?= null
private var clickListener: ClickListener? = null
private val selectedUploadRecord = ArrayList<TakeOverRecordInfo>()
@@ -83,36 +93,6 @@ class TakeOverRecordView @JvmOverloads constructor(
)
rvTakeOverList.adapter = takeOverListAdapter
val list = ArrayList<TakeOverRecordInfo>()
// GlobalScope.launch(Dispatchers.IO){
// list = CallerTakeOverManager.getAllRecord(context)
// }
val takeOverRecordInfoOne = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineNamelineNamelineNamelineNamelineNamelineNamelineNamelineNamelineNamelineName","描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1描述1",false)
val takeOverRecordInfoTwo = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述2",false)
val takeOverRecordInfoThree = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述3",true)
val takeOverRecordInfoFour = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述4",true)
val takeOverRecordInfoFive = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述5",false)
val takeOverRecordInfoSix = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述6",false)
val takeOverRecordInfoSeven = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述7",false)
val takeOverRecordInfoEight = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述8",true)
val takeOverRecordInfoNine = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述9",false)
val takeOverRecordInfoTen = TakeOverRecordInfo(System.currentTimeMillis().toString(),"环球贸易中心",1,2,3,"lineName","描述10",true)
list.add(takeOverRecordInfoOne)
list.add(takeOverRecordInfoTwo)
list.add(takeOverRecordInfoThree)
list.add(takeOverRecordInfoFour)
list.add(takeOverRecordInfoFive)
list.add(takeOverRecordInfoSix)
list.add(takeOverRecordInfoSeven)
list.add(takeOverRecordInfoEight)
list.add(takeOverRecordInfoNine)
list.add(takeOverRecordInfoTen)
takeOverListAdapter?.setData(list)
//一键上传
tvUpload.setOnClickListener {
@@ -121,6 +101,23 @@ class TakeOverRecordView @JvmOverloads constructor(
tvDeleteSelect.setOnClickListener {
// CallerTakeOverManager.deleteRecord(context,)
}
scope.launch(Dispatchers.IO){
val recordList= CallerTakeOverManager.getAllRecord(context)
ThreadUtils.runOnUiThread {
if(recordList.isEmpty()){
tvRecordNoData.visibility = View.VISIBLE
recordGroup.visibility = View.GONE
}else{
tvRecordNoData.visibility = View.GONE
recordGroup.visibility = View.VISIBLE
//更新列表
takeOverListAdapter?.setData(recordList)
}
}
}
}
fun setOnClickListener(clickListener: ClickListener) {

View File

@@ -75,7 +75,7 @@ class WorkOrderManager{
CallerDevaToolsListenerManager.invokeProblemPadAddSuccess()
},
onError = {
CallerDevaToolsListenerManager.invokeProblemPadAddError()
CallerDevaToolsListenerManager.invokeProblemPadAddError(it)
}
)
}

View File

@@ -53,7 +53,7 @@ class WorkOrderNetWorkModel {
onSuccess.invoke("")
}
onError{
onError.invoke("")
onError.invoke(it.message+"")
}
}
}

View File

@@ -35,7 +35,6 @@ class TakeOverListAdapter(private val context: Context): RecyclerView.Adapter<Ta
override fun onBindViewHolder(holder: TakeOverRecordHolder, position: Int) {
data?.let {
val recordEntity = it[position]
holder.cbRecordSelect.isClickable = !recordEntity.reportStatus
holder.cbRecordSelect.setOnCheckedChangeListener { _, isChecked ->
clickListener?.onSelectRecord(recordEntity,isChecked)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -266,7 +266,7 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@drawable/report_button_bg"
android:text="@string/take_over_report"
android:text="@string/fault_report"
android:textColor="#FFFFFF"
android:textSize="@dimen/sp_27"
android:textStyle="bold"

View File

@@ -111,7 +111,7 @@
android:textSize="@dimen/sp_26"
android:textColor="@color/white"
app:drawableTopCompat="@drawable/icon_report_success"
android:layout_marginTop="@dimen/dp_59"
android:layout_marginTop="@dimen/dp_79"
android:drawablePadding="@dimen/dp_22"
android:visibility="gone"
/>

View File

@@ -207,7 +207,7 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@drawable/report_button_bg"
android:text="@string/take_over_report"
android:text="@string/take_over_save"
android:textColor="#FFFFFF"
android:textSize="@dimen/sp_27"
android:textStyle="bold"

View File

@@ -92,6 +92,30 @@
android:gravity="center"
/>
<androidx.constraintlayout.widget.Group
android:id="@+id/recordGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="tvTakeOverRecordDate,
rvTakeOverList,tvUpload,tvDeleteSelect"
android:visibility="gone"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tvRecordNoData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="@dimen/dp_652"
app:drawableTopCompat="@drawable/icon_record_no_data"
android:text="@string/take_over_record_no_data"
android:drawablePadding="@dimen/dp_33"
android:textColor="#CAD6FF"
android:textSize="@dimen/sp_34"
android:gravity="center_horizontal"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -61,7 +61,9 @@
<string name="fault_note_supplement">(选填)</string>
<string name="take_over_note_input">手动输入</string>
<string name="take_over_note_audio">补充描述语音输入</string>
<string name="take_over_report">上报</string>
<string name="fault_report">上报</string>
<string name="take_over_save">保存</string>
<string name="take_over_cancel">取消</string>
<string name="take_over_record_no_data">暂无接管记录</string>
</resources>

View File

@@ -58,7 +58,7 @@ interface IMoGoDevaToolsListener {
fun problemPadAddSuccess(){}
fun problemPadAddError(){}
fun problemPadAddError(msg: String){}
fun getCategoriesSuccess(list: List<CategoryInfo>){}

View File

@@ -92,10 +92,10 @@ object CallerDevaToolsListenerManager : CallerBase<IMoGoDevaToolsListener>() {
/**
* 上报故障到运营平台失败
*/
fun invokeProblemPadAddError(){
fun invokeProblemPadAddError(msg: String){
M_LISTENERS.forEach{
val listener = it.value
listener.problemPadAddError()
listener.problemPadAddError(msg)
}
}