diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/RecordManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/RecordManager.kt new file mode 100644 index 0000000000..d6457f8dda --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/RecordManager.kt @@ -0,0 +1,154 @@ +package com.mogo.eagle.core.function.takeover + +import android.content.Context +import android.os.Looper +import com.mogo.eagle.core.data.deva.report.TakeOverRecordInfo +import com.mogo.eagle.core.function.takeover.db.RecordDb +import com.mogo.eagle.core.function.takeover.db.RecordInfo +import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope +import com.mogo.eagle.core.utilcode.util.Utils +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext + +/** + * 接管记录数据库操作管理 + */ +object RecordManager { + + private val scope by lazy { + Utils.getApp().lifeCycleScope + } + + /** + * 插入接管记录数据 + * @param context 上下文 + * @param takeOverRecordInfo 接管数据实体 + */ + fun insertRecord(context: Context,takeOverRecordInfo: TakeOverRecordInfo){ + takeOverRecordInfo.let { + val recordInfo = RecordInfo(null,it.address,it.faultStartTime,it.level1Id, + it.level2Id,it.level3Id,it.lineName,it.reportNote,it.reportStatus) + if (Thread.currentThread() == Looper.getMainLooper().thread){ + scope.launch{ + withContext(Dispatchers.IO){ + realInsertRecord(context,recordInfo) + } + } + }else{ + realInsertRecord(context,recordInfo) + } + } + } + + /** + * 插入接管记录数据 + * @param context 上下文 + * @param recordInfo 接管数据实体 + */ + private fun realInsertRecord(context: Context,recordInfo: RecordInfo){ + RecordDb.getDb(context) + .recordDao() + .insertRecord(recordInfo) + } + + /** + * 修改接管记录数据 + * @param context 上下文 + * @param takeOverRecordInfo 接管数据实体 + */ + fun updateRecord(context: Context,takeOverRecordInfo: TakeOverRecordInfo){ + takeOverRecordInfo.let{ + val recordInfo = RecordInfo(null,it.address,it.faultStartTime,it.level1Id, + it.level2Id,it.level3Id,it.lineName,it.reportNote,it.reportStatus) + if (Thread.currentThread() == Looper.getMainLooper().thread){ + scope.launch{ + withContext(Dispatchers.IO){ + realUpdateRecord(context,recordInfo) + } + } + }else{ + realUpdateRecord(context,recordInfo) + } + } + } + + /** + * 修改接管记录数据 + * @param context 上下文 + * @param recordInfo 接管数据实体 + */ + private fun realUpdateRecord(context: Context,recordInfo: RecordInfo){ + RecordDb.getDb(context) + .recordDao() + .updateRecord(recordInfo) + } + + /** + * 删除接管记录 + * @param context 上下文 + * @param recordInfo 接管数据实体 + */ + fun deleteRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo) { + takeOverRecordInfo.let{ + val recordInfo = RecordInfo(null,it.address,it.faultStartTime,it.level1Id, + it.level2Id,it.level3Id,it.lineName,it.reportNote,it.reportStatus) + if (Thread.currentThread() == Looper.getMainLooper().thread){ + scope.launch { + withContext(Dispatchers.IO) { + realDeleteRecord(context, recordInfo) + } + } + }else{ + realDeleteRecord(context, recordInfo) + } + } + } + + /** + * 删除接管记录 + * @param context 上下文 + * @param recordInfo 接管数据实体 + */ + private fun realDeleteRecord(context: Context, recordInfo: RecordInfo){ + RecordDb.getDb(context) + .recordDao() + .deleteRecord(recordInfo) + } + + /** + * 获取接管记录列表 + */ + suspend fun getAllRecord(context: Context): List{ + return RecordDb.getDb(context) + .recordDao() + .getAllRecord() + } + + /** + * 删除所有接管数据 + * @param context 上下文 + */ + fun deleteAllRecord(context: Context){ + if (Thread.currentThread() == Looper.getMainLooper().thread){ + scope.launch { + withContext(Dispatchers.IO) { + realDeleteAllRecord(context) + } + } + }else{ + realDeleteAllRecord(context) + } + } + + /** + * 删除所有接管数据 + * @param context 上下文 + */ + private fun realDeleteAllRecord(context: Context){ + RecordDb.getDb(context) + .recordDao() + .deleteAllRecord() + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/TakeOverRecordProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/TakeOverRecordProvider.kt new file mode 100644 index 0000000000..65ab11b001 --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/TakeOverRecordProvider.kt @@ -0,0 +1,55 @@ +package com.mogo.eagle.core.function.takeover + +import android.content.Context +import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.eagle.core.data.constants.MogoServicePaths +import com.mogo.eagle.core.data.deva.report.TakeOverRecordInfo +import com.mogo.eagle.core.function.api.datacenter.takeover.ITakeOverProvider + +@Route(path = MogoServicePaths.PATH_TAKE_OVER_PROVIDER) +class TakeOverRecordProvider: ITakeOverProvider { + + override val functionName: String + get() = "TakeOverRecordProvider" + + override fun init(context: Context?) { + + } + + override fun onDestroy() { + + } + + override fun insertRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo) { + RecordManager.insertRecord(context,takeOverRecordInfo) + } + + override fun updateRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo) { + RecordManager.updateRecord(context,takeOverRecordInfo) + } + + override fun deleteRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo) { + RecordManager.deleteRecord(context,takeOverRecordInfo) + } + + override fun deleteAllRecord(context: Context) { + RecordManager.deleteAllRecord(context) + } + + override suspend fun getAllRecord(context: Context): List { + val list = RecordManager.getAllRecord(context) + return if(list.isEmpty()){ + emptyList() + }else{ + val recordInfoList = mutableListOf() + list.forEach { + recordInfoList.add( + TakeOverRecordInfo(it.faultStartTime,it.address,it.level1Id, + it.level2Id,it.level3Id,it.lineName,it.reportNote,it.reportStatus) + ) + } + recordInfoList + } + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDao.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDao.kt new file mode 100644 index 0000000000..dc49a516ea --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDao.kt @@ -0,0 +1,30 @@ +package com.mogo.eagle.core.function.takeover.db + +import androidx.room.Dao +import androidx.room.Delete +import androidx.room.Insert +import androidx.room.Query +import androidx.room.Update + +/** + * 接管记录实体类数据库操作 + */ +@Dao +interface RecordDao { + //插入数据 + @Insert + fun insertRecord(info: RecordInfo) + //修改数据 + @Update + fun updateRecord(info: RecordInfo) + //删除数据 + @Delete + fun deleteRecord(info: RecordInfo) + //查询数据 + @Query("SELECT * FROM take_over_record") + suspend fun getAllRecord(): List + //清空数据 + @Query("DELETE FROM take_over_record") + fun deleteAllRecord() + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDb.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDb.kt new file mode 100644 index 0000000000..8abcecddb9 --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDb.kt @@ -0,0 +1,32 @@ +package com.mogo.eagle.core.function.takeover.db + +import android.content.Context +import androidx.room.Database +import androidx.room.Room +import androidx.room.RoomDatabase + +/** + * 接管记录数据库 + */ +@Database(entities = [RecordInfo::class], version = 1, exportSchema = false) +abstract class RecordDb: RoomDatabase() { + + abstract fun recordDao(): RecordDao + + companion object { + private const val RECORD_DB_NAME = "take_over.db" + + private var db: RecordDb? = null + + @JvmStatic + fun getDb(context: Context): RecordDb { + if (db == null) { + db = Room.databaseBuilder(context.applicationContext, RecordDb::class.java, RECORD_DB_NAME) + .fallbackToDestructiveMigration() + .build() + } + return db!! + } + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordInfo.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordInfo.kt new file mode 100644 index 0000000000..93ad9ecb72 --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordInfo.kt @@ -0,0 +1,39 @@ +package com.mogo.eagle.core.function.takeover.db + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +/** + * 接管记录实体类 + */ +@Entity(tableName = "take_over_record") +data class RecordInfo( + //自增主键 + @PrimaryKey(autoGenerate = true) + var id: Int ?= null, + //故障地点 + @ColumnInfo + val address: String, + //故障开始时间 yyyy-MM-dd HH:mm:ss + @ColumnInfo + val faultStartTime: String, + //一级分类ID + @ColumnInfo + var level1Id: Int, + //二级分类ID + @ColumnInfo + var level2Id: Int, + //三级分类ID + @ColumnInfo + var level3Id: Int, + //行驶路线 + @ColumnInfo + val lineName: String, + //上报描述 + @ColumnInfo + var reportNote: String, + //上传状态 false:未上传,可编辑 true:已上传,不可编辑 + @ColumnInfo + var reportStatus: Boolean +) \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/ReportTypeWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/ReportTypeWindow.kt new file mode 100644 index 0000000000..89c1c8e403 --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/ReportTypeWindow.kt @@ -0,0 +1,42 @@ +package com.zhjt.mogo_core_function_devatools.workorder + +import android.annotation.SuppressLint +import android.app.Activity +import android.view.LayoutInflater +import android.view.View +import android.view.WindowManager +import com.zhjt.mogo_core_function_devatools.R +import com.zhjt.mogo_core_function_devatools.badcase.record.RecordManager + +/** + * 上报类型选择,包括一键上报及上报类型选择:故障类、接管类 + * 一键上报和类型选择互斥,当点击弹出上报类型选择时,一键上报隐藏 + */ +class ReportTypeWindow constructor(activity: Activity) { + + companion object{ + const val TAG = "ReportTypeWindow" + } + + private var mActivity: Activity = activity + private var mWindowParams: WindowManager.LayoutParams? = null + private var mWindowManager: WindowManager? = null + private lateinit var mFloatLayout: View + + init { + initFloatWindow() + } + + @SuppressLint("InflateParams") + private fun initFloatWindow(){ + mFloatLayout = LayoutInflater.from(mActivity).inflate(R.layout.view_report_type, null) as View + + + + + } + + + + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverReasonWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverReasonWindow.kt new file mode 100644 index 0000000000..bc28279525 --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverReasonWindow.kt @@ -0,0 +1,348 @@ +package com.zhjt.mogo_core_function_devatools.workorder + + +import android.annotation.SuppressLint +import android.app.Activity +import android.graphics.PixelFormat +import android.os.Bundle +import android.text.Editable +import android.text.TextWatcher +import android.util.DisplayMetrics +import android.util.Log +import android.view.Gravity +import android.view.LayoutInflater +import android.view.MotionEvent +import android.view.View +import android.view.View.OnFocusChangeListener +import android.view.WindowManager +import android.view.animation.Animation +import android.view.animation.ScaleAnimation +import android.widget.EditText +import android.widget.ImageView +import android.widget.TextView +import androidx.appcompat.widget.AppCompatEditText +import androidx.constraintlayout.widget.Group +import androidx.recyclerview.widget.RecyclerView +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.eagle.core.function.call.devatools.CallerDevaToolsListenerManager +import com.mogo.eagle.core.utilcode.util.BarUtils +import com.mogo.eagle.core.utilcode.util.JsonParser +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 kotlinx.coroutines.DelicateCoroutinesApi +import kotlin.math.absoluteValue + +/** + * 接管原因编辑窗口 + */ +class TakeOverReasonWindow constructor(activity: Activity) : View.OnTouchListener{ + + companion object{ + const val TAG = "TakeOverReasonWindow" + } + + private var mActivity: Activity = activity + private var mWindowParams: WindowManager.LayoutParams? = null + private var mWindowManager: WindowManager? = null + private lateinit var mFloatLayout: View + + private var mInViewX = 0f + private var mInViewY = 0f + private var mInScreenX = 0f + private var mInScreenY = 0f + + // 语音听写对象 + private var mIat: SpeechRecognizer? = null + // 用HashMap存储听写结果 + private val mIatResults: HashMap = LinkedHashMap() + + var ret = 0 // 函数调用返回值 + private var audioStatus = false + + private var workOrderOccurrenceTime = System.currentTimeMillis() //故障发生时间 + + private var clickListener: ClickListener? = null + + private lateinit var tvTakeOverTitle: TextView + private lateinit var tvTakeOverTime: TextView + private lateinit var tvFaultType: TextView + private lateinit var ivFaultTypeSelect: ImageView + private lateinit var tvFaultReason: TextView + private lateinit var ivFaultReasonSelect: ImageView + private lateinit var ivTimeReduce: ImageView + private lateinit var tvOccurrenceTime: TextView + private lateinit var ivTimeAdd: ImageView + private lateinit var etNoteInput: AppCompatEditText + private lateinit var ivNoteAudio: ImageView + private lateinit var tvTakeOverReport: TextView + private lateinit var tvTakeOverCancel: TextView + private lateinit var rvFaultList: RecyclerView + private lateinit var tvUploadSuccess: TextView + private lateinit var takeOverReasonGroup: Group + + init { + initFloatWindow() + } + + @SuppressLint("InflateParams") + private fun initFloatWindow(){ + mFloatLayout = LayoutInflater.from(mActivity).inflate(R.layout.view_take_over_reason, null) as View + mFloatLayout.setOnTouchListener(this) + + // 初始化识别无UI识别对象 + // 使用SpeechRecognizer对象,可根据回调消息自定义界面; + mIat = SpeechRecognizer.createRecognizer(mActivity, mInitListener) + initView() + initEvent() + mWindowParams = WindowManager.LayoutParams() + mWindowManager = mActivity.windowManager + mWindowParams?.let { + it.format = PixelFormat.RGBA_8888 + it.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL + it.gravity = Gravity.START or Gravity.TOP + it.width = 844 + it.height = 991 + it.alpha = 1.0f + } + } + + private fun initView(){ + tvTakeOverTitle = mFloatLayout.findViewById(R.id.tvTakeOverTitle) + tvTakeOverTime = mFloatLayout.findViewById(R.id.tvTakeOverTime) + tvFaultType = mFloatLayout.findViewById(R.id.tvFaultType) + ivFaultTypeSelect = mFloatLayout.findViewById(R.id.ivFaultTypeSelect) + tvFaultReason = mFloatLayout.findViewById(R.id.tvFaultReason) + ivFaultReasonSelect = mFloatLayout.findViewById(R.id.ivFaultReasonSelect) + ivTimeReduce = mFloatLayout.findViewById(R.id.ivTimeReduce) + tvOccurrenceTime = mFloatLayout.findViewById(R.id.tvOccurrenceTime) + ivTimeAdd = mFloatLayout.findViewById(R.id.ivTimeAdd) + etNoteInput = mFloatLayout.findViewById(R.id.etNoteInput) + ivNoteAudio = mFloatLayout.findViewById(R.id.ivNoteAudio) + tvTakeOverReport = mFloatLayout.findViewById(R.id.tvTakeOverReport) + tvTakeOverCancel = mFloatLayout.findViewById(R.id.tvTakeOverCancel) + rvFaultList = mFloatLayout.findViewById(R.id.rvFaultList) + tvUploadSuccess = mFloatLayout.findViewById(R.id.tvUploadSuccess) + takeOverReasonGroup = mFloatLayout.findViewById(R.id.takeOverReasonGroup) + } + + @OptIn(DelicateCoroutinesApi::class) + @SuppressLint("SetTextI18n") + private fun initEvent(){ + //弹窗展示时间 + tvTakeOverTime.text = mActivity.resources.getString(R.string.take_over_time) + + millis2String(System.currentTimeMillis(), TimeUtils.getHourMinSecondFormat()) + //发生时间 + tvOccurrenceTime.text = millis2String(workOrderOccurrenceTime, TimeUtils.getHourMinFormat()) + ivTimeReduce.setOnClickListener { + workOrderOccurrenceTime -= 60000 + tvOccurrenceTime.text = millis2String(workOrderOccurrenceTime, TimeUtils.getHourMinFormat()) + } + ivTimeAdd.setOnClickListener { + if(workOrderOccurrenceTime + 60000 > System.currentTimeMillis()){ + ToastUtils.showShort("发生时间应在当前时间之前") + return@setOnClickListener + } + workOrderOccurrenceTime += 60000 + tvOccurrenceTime.text = millis2String(workOrderOccurrenceTime, TimeUtils.getHourMinFormat()) + } + //补充描述 + etNoteInput.onFocusChangeListener = OnFocusChangeListener { v, hasFocus -> + val edit = v as EditText + if(hasFocus){ + edit.hint = "" + }else{ + edit.hint = "手动输入" + } + } + etNoteInput.addTextChangedListener(object: TextWatcher{ + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { + + } + + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + + } + + override fun afterTextChanged(s: Editable?) { + + } + + }) + //问题描述录音 + ivNoteAudio.setOnClickListener { + audioStatus = !audioStatus + setAudio(audioStatus) + } + //上报 + tvTakeOverReport.setOnClickListener{ + //TODO + } + //取消 + tvTakeOverCancel.setOnClickListener { + clickListener?.closeWindow() + } + + } + + private fun setAudio(status: Boolean){ + if(status){ + //开始录音 + mIat?.let { + //清空之前的内容 + mIatResults.clear() + SpeechUtils.setParam(it) + // 不显示听写对话框 + ret = it.startListening(mRecognizerListener) + if (ret != ErrorCode.SUCCESS) { + ToastUtils.showShort("听写失败,错误码:$ret,请点击网址https://www.xfyun.cn/document/error-code查询解决方案") + } + } + //开始录音,展示放大缩小动效 + val scaleAnimation = ScaleAnimation( + 1.0f, 0.8f, 1.0f, 0.8f, + Animation.RELATIVE_TO_SELF, 0.8f, Animation.RELATIVE_TO_SELF, 0.8f + ) + scaleAnimation.duration = 1000 + scaleAnimation.repeatCount = -1 + ivNoteAudio.startAnimation(scaleAnimation) + }else{ + //停止语音听写 + mIat?.stopListening() + //结束动画 + ivNoteAudio.clearAnimation() + } + } + + /** + * 初始化监听器。 + */ + private val mInitListener = InitListener { code -> + if (code != ErrorCode.SUCCESS) { + ToastUtils.showShort("讯飞语音听写初始化失败,错误码:$code") + } + } + + /** + * 听写监听器。 + */ + private val mRecognizerListener: RecognizerListener = object : RecognizerListener{ + override fun onVolumeChanged(p0: Int, p1: ByteArray?) { + //showTip("当前正在说话,音量大小 = " + volume + " 返回音频数据 = " + data.length); + } + + override fun onBeginOfSpeech() { + // 此回调表示:sdk内部录音机已经准备好了,用户可以开始语音输入 + } + + override fun onEndOfSpeech() { + // 此回调表示:检测到了语音的尾端点,已经进入识别过程,不再接受语音输入 + } + + override fun onResult(results: RecognizerResult?, isLast: Boolean) { + results?.let { + printResult(it) + } + } + + override fun onError(p0: SpeechError?) { + // Tips: + // 错误码:10118(您没有说话),可能是录音机权限被禁,需要提示用户打开应用的录音权限。 + } + + override fun onEvent(p0: Int, p1: Int, p2: Int, p3: Bundle?) { + // 以下代码用于获取与云端的会话id,当业务出错时将会话id提供给技术支持人员,可用于查询会话日志,定位出错原因 + // 若使用本地能力,会话id为null + // if (SpeechEvent.EVENT_SESSION_ID == eventType) { + // String sid = obj.getString(SpeechEvent.KEY_EVENT_SESSION_ID); + // Log.d(TAG, "session id =" + sid); + // } + } + + } + + /** + * 显示结果 + */ + @SuppressLint("SetTextI18n") + private fun printResult(results: RecognizerResult) { + val text: String = JsonParser.parseIatResult(results.resultString) + Log.i(TAG, "语音内容=$text") + if(text.isNotEmpty()){ + if(etNoteInput.text.toString().isEmpty()){ + etNoteInput.setText(text) + etNoteInput.setSelection(text.length) + }else{ + val startStr = etNoteInput.text.toString().substring(0,etNoteInput.selectionStart) + val endStr = etNoteInput.text.toString().substring(etNoteInput.selectionEnd,etNoteInput.text.toString().length) + etNoteInput.setText(startStr+text+endStr) + etNoteInput.setSelection(startStr.length+text.length) + } + + } + } + + + @SuppressLint("ClickableViewAccessibility") + override fun onTouch(v: View?, motionEvent: MotionEvent?): Boolean { + when (motionEvent?.action) { + MotionEvent.ACTION_DOWN -> { + // 获取相对View的坐标,即以此View左上角为原点 + mInViewX = motionEvent.x + mInViewY = motionEvent.y + // 获取相对屏幕的坐标,即以屏幕左上角为原点 + mInScreenX = motionEvent.rawX + mInScreenY = motionEvent.rawY + } + MotionEvent.ACTION_MOVE -> { + // 更新浮动窗口位置参数 + mInScreenX = motionEvent.rawX + mInScreenY = motionEvent.rawY + if(((mInScreenX - mInViewX)-mWindowParams!!.x).absoluteValue>150 || ((mInScreenY - mInViewY)-mWindowParams!!.y).absoluteValue>150){ + return true + } + mWindowParams!!.x = (mInScreenX - mInViewX).toInt() + mWindowParams!!.y = (mInScreenY - mInViewY).toInt() + // 手指移动的时候更新小悬浮窗的位置 + mWindowManager!!.updateViewLayout(mFloatLayout, mWindowParams) + } + } + return true + } + + fun showFloatWindow() { + if (mFloatLayout.parent == null) { + val metrics = DisplayMetrics() + // 默认固定位置,靠屏幕右边缘的中间 + mWindowManager!!.defaultDisplay.getMetrics(metrics) + mWindowParams!!.x = metrics.widthPixels-890 + mWindowParams!!.y = metrics.heightPixels - BarUtils.getStatusBarHeight()-1140 + mWindowManager!!.addView(mFloatLayout, mWindowParams) + + + } + } + + fun hideFloatWindow() { + if (mFloatLayout.parent != null){ + mWindowManager!!.removeView(mFloatLayout) + } + CallerDevaToolsListenerManager.removeListener(TAG) + } + + fun setClickListener(clickListener: ClickListener) { + this.clickListener = clickListener + } + + interface ClickListener { + fun closeWindow() + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverRecordView.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverRecordView.kt new file mode 100644 index 0000000000..1033bc99ed --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/TakeOverRecordView.kt @@ -0,0 +1,53 @@ +package com.zhjt.mogo_core_function_devatools.workorder + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.recyclerview.widget.LinearLayoutManager +import com.mogo.eagle.core.function.call.takeover.CallerTakeOverManager +import com.zhjt.mogo_core_function_devatools.R +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.rvTakeOverList +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch + +/** + * 接管信息管理页面 + */ +class TakeOverRecordView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + companion object { + const val TAG = "TakeOverRecordView" + } + + private var takeOverListAdapter: TakeOverListAdapter ?= null + + init { + LayoutInflater.from(context).inflate(R.layout.view_take_over_record, this, true) + initView() + } + + private fun initView(){ + //关闭窗口 + ivTakeOverRecordClose.setOnClickListener { + + } + takeOverListAdapter = TakeOverListAdapter() + val linearLayoutManager = LinearLayoutManager(context) + rvTakeOverList.layoutManager = linearLayoutManager + rvTakeOverList.adapter = takeOverListAdapter + + GlobalScope.launch(Dispatchers.IO){ + CallerTakeOverManager.getAllRecord(context) + } + + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/adapter/TakeOverListAdapter.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/adapter/TakeOverListAdapter.kt new file mode 100644 index 0000000000..3eff0b4be8 --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/workorder/adapter/TakeOverListAdapter.kt @@ -0,0 +1,48 @@ +package com.zhjt.mogo_core_function_devatools.workorder.adapter + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.CheckBox +import android.widget.ImageView +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.mogo.eagle.core.data.deva.report.TakeOverRecordInfo +import com.zhjt.mogo_core_function_devatools.R + +/** + * 接管记录适配器 + */ +class TakeOverListAdapter: RecyclerView.Adapter() { + + private var data:List ?= null + + fun setData(data: List){ + this.data = data + notifyDataSetChanged() + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TakeOverRecordHolder { + val view = LayoutInflater.from(parent.context) + .inflate(R.layout.item_take_over_record, parent, false) + return TakeOverRecordHolder(view) + } + + override fun onBindViewHolder(holder: TakeOverRecordHolder, position: Int) { + data?.let { + val recordEntity = it[position] + + } + } + + override fun getItemCount() = data?.size ?: 0 + + class TakeOverRecordHolder(itemView: View) : RecyclerView.ViewHolder(itemView){ + val cbRecordSelect: CheckBox = itemView.findViewById(R.id.cbRecordSelect) + val tvFaultStartTime: TextView = itemView.findViewById(R.id.tvFaultStartTime) + val ivRecordStatusLabel: ImageView = itemView.findViewById(R.id.ivRecordStatusLabel) + val tvLineName: TextView = itemView.findViewById(R.id.tvLineName) + val tvTakeOverReason: TextView = itemView.findViewById(R.id.tvTakeOverReason) + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_fault_type.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_fault_type.xml new file mode 100644 index 0000000000..cb1fa5e3d6 --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_fault_type.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_report_type.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_report_type.png new file mode 100644 index 0000000000..086df44466 Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_report_type.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_take_over_reason.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_take_over_reason.png new file mode 100644 index 0000000000..778b364988 Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/bg_take_over_reason.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_fault_expand.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_fault_expand.png new file mode 100644 index 0000000000..d693c8edff Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_fault_expand.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_fault_retract.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_fault_retract.png new file mode 100644 index 0000000000..15463ade67 Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_fault_retract.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_one_click_report.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_one_click_report.png new file mode 100644 index 0000000000..3f8896bb9b Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_one_click_report.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_record_edit.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_record_edit.png new file mode 100644 index 0000000000..bbc42712b6 Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_record_edit.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_record_upload.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_record_upload.png new file mode 100644 index 0000000000..1f515f9740 Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_record_upload.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_report_success.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_report_success.png new file mode 100644 index 0000000000..780bc679fd Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_report_success.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_take_over_upload_success.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_take_over_upload_success.png new file mode 100644 index 0000000000..e4d5d55d73 Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_take_over_upload_success.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_type_fault.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_type_fault.png new file mode 100644 index 0000000000..da965e4c1b Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_type_fault.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_type_take_over.png b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_type_take_over.png new file mode 100644 index 0000000000..64e9ca419f Binary files /dev/null and b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/icon_type_take_over.png differ diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/record_radio_button_style.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/record_radio_button_style.xml new file mode 100644 index 0000000000..2b50242af5 --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/drawable/record_radio_button_style.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/item_take_over_record.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/item_take_over_record.xml new file mode 100644 index 0000000000..0e24c865bc --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/item_take_over_record.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_report_type.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_report_type.xml new file mode 100644 index 0000000000..e1411f0b3e --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_report_type.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_reason.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_reason.xml new file mode 100644 index 0000000000..078d14811e --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_reason.xml @@ -0,0 +1,363 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_record.xml b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_record.xml new file mode 100644 index 0000000000..2cc90ddbf1 --- /dev/null +++ b/core/function-impl/mogo-core-function-devatools/src/main/res/layout/view_take_over_record.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/report/TakeOverRecordInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/report/TakeOverRecordInfo.kt new file mode 100644 index 0000000000..8b90e06d46 --- /dev/null +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/report/TakeOverRecordInfo.kt @@ -0,0 +1,16 @@ +package com.mogo.eagle.core.data.deva.report + +/** + * 接管记录实体类 + * @param faultStartTime 故障开始时间 yyyy-MM-dd HH:mm:ss + * @param address 故障地点 + * @param level1Id 一级分类ID + * @param level2Id 二级分类ID + * @param level3Id 三级分类ID + * @param lineName 行驶路线 + * @param reportNote 上报描述 + * @param reportStatus 上传状态 false:未上传,可编辑 true:已上传,不可编辑 + */ +data class TakeOverRecordInfo(var faultStartTime: String, var address:String, + var level1Id: Int, var level2Id: Int, var level3Id: Int, + var lineName: String, var reportNote: String, var reportStatus: Boolean) \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/datacenter/takeover/ITakeOverProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/datacenter/takeover/ITakeOverProvider.kt new file mode 100644 index 0000000000..521d1f7e36 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/datacenter/takeover/ITakeOverProvider.kt @@ -0,0 +1,37 @@ +package com.mogo.eagle.core.function.api.datacenter.takeover + +import android.content.Context +import com.mogo.eagle.core.data.deva.report.TakeOverRecordInfo +import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider + +/** + * 接管记录数据中心 + */ +interface ITakeOverProvider: IMoGoFunctionServerProvider { + + /** + * 插入接管记录数据 + */ + fun insertRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo) + + /** + * 修改接管记录数据 + */ + fun updateRecord(context: Context,takeOverRecordInfo: TakeOverRecordInfo) + + /** + * 删除接管记录 + */ + fun deleteRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo) + + /** + * 删除所有接管数据 + */ + fun deleteAllRecord(context: Context) + + /** + * 获取接管记录列表 + */ + suspend fun getAllRecord(context: Context): List + +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/takeover/CallerTakeOverManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/takeover/CallerTakeOverManager.kt new file mode 100644 index 0000000000..27e962afa9 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/takeover/CallerTakeOverManager.kt @@ -0,0 +1,55 @@ +package com.mogo.eagle.core.function.call.takeover + +import android.content.Context +import com.mogo.eagle.core.data.constants.MogoServicePaths +import com.mogo.eagle.core.data.deva.report.TakeOverRecordInfo +import com.mogo.eagle.core.function.api.datacenter.takeover.ITakeOverProvider +import com.mogo.eagle.core.function.call.base.CallerBase + +/** + * 接管记录管理 + */ +object CallerTakeOverManager { + + private val providerApi: ITakeOverProvider + get() = CallerBase.getApiInstance( + ITakeOverProvider::class.java, + MogoServicePaths.PATH_TAKE_OVER_PROVIDER + ) + + /** + * 插入接管记录数据 + */ + fun insertRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo){ + providerApi.insertRecord(context, takeOverRecordInfo) + } + + /** + * 修改接管记录数据 + */ + fun updateRecord(context: Context,takeOverRecordInfo: TakeOverRecordInfo){ + providerApi.updateRecord(context, takeOverRecordInfo) + } + + /** + * 删除接管记录 + */ + fun deleteRecord(context: Context, takeOverRecordInfo: TakeOverRecordInfo){ + providerApi.deleteRecord(context, takeOverRecordInfo) + } + + /** + * 删除所有接管数据 + */ + fun deleteAllRecord(context: Context){ + providerApi.deleteAllRecord(context) + } + + /** + * 获取接管记录列表 + */ + suspend fun getAllRecord(context: Context): List{ + return providerApi.getAllRecord(context) + } + +} \ No newline at end of file