Parcourir la source

refactor(更新)
- 异常上报添加完成

周文健 il y a 4 mois
Parent
commit
3647af070d
21 fichiers modifiés avec 286 ajouts et 52 suppressions
  1. 15 16
      app/src/main/java/com/grkj/iscs/features/main/dialog/TextDropDownDialog.kt
  2. 51 24
      app/src/main/java/com/grkj/iscs/features/main/fragment/exception_manage/ExceptionReportFragment.kt
  3. 2 0
      app/src/main/java/com/grkj/iscs/features/main/fragment/job_manage/JobManageFragment.kt
  4. 101 7
      app/src/main/java/com/grkj/iscs/features/main/viewmodel/exception_manage/ExceptionViewModel.kt
  5. 2 0
      app/src/main/java/com/grkj/iscs/features/main/viewmodel/job_manage/JobManageViewModel.kt
  6. 2 1
      app/src/main/res/layout/fragment_exception_report.xml
  7. 3 0
      app/src/main/res/navigation/nav_job_manage.xml
  8. 15 0
      data/src/main/java/com/grkj/data/dao/ExceptionDao.kt
  9. 6 0
      data/src/main/java/com/grkj/data/dao/HardwareDao.kt
  10. 12 0
      data/src/main/java/com/grkj/data/dao/JobTicketDao.kt
  11. 1 1
      data/src/main/java/com/grkj/data/model/dos/IsExceptionSourceStandard.kt
  12. 6 3
      data/src/main/java/com/grkj/data/model/dos/IsExceptionStandard.kt
  13. 12 0
      data/src/main/java/com/grkj/data/repository/IExceptionRepository.kt
  14. 5 0
      data/src/main/java/com/grkj/data/repository/IHardwareRepository.kt
  15. 10 0
      data/src/main/java/com/grkj/data/repository/IJobTicketRepository.kt
  16. 10 0
      data/src/main/java/com/grkj/data/repository/impl/network/NetworkExceptionRepository.kt
  17. 4 0
      data/src/main/java/com/grkj/data/repository/impl/network/NetworkHardwareRepository.kt
  18. 8 0
      data/src/main/java/com/grkj/data/repository/impl/network/NetworkJobTicketRepository.kt
  19. 9 0
      data/src/main/java/com/grkj/data/repository/impl/standard/ExceptionRepository.kt
  20. 4 0
      data/src/main/java/com/grkj/data/repository/impl/standard/HardwareRepository.kt
  21. 8 0
      data/src/main/java/com/grkj/data/repository/impl/standard/JobTicketRepository.kt

+ 15 - 16
app/src/main/java/com/grkj/iscs/features/main/dialog/TextDropDownDialog.kt

@@ -49,27 +49,25 @@ class TextDropDownDialog(
                 onBind {
                     val item = getModel<TextDropDownEntity>()
                     val itemBinding = getBinding<ItemHomeTextDropDownBinding>()
+                    itemBinding.arrowIv.isVisible = item.getChildren().isNotEmpty()
                     // 缩进
                     itemBinding.rootLayout.setPadding(indentPx * item.getLevel(), 0, 0, 0)
-                    // 展开/收起
-                    itemBinding.rootLayout.setOnClickListener {
-                        if (item.getChildren().isEmpty()) {
-                            return@setOnClickListener
-                        }
-                        if (item.itemExpand) collapse() else expand()
-                        itemBinding.arrowIv.rotation = if (item.itemExpand) 90f else 0f
-                    }
                     itemBinding.arrowIv.rotation = if (item.itemExpand) 90f else 0f
                     // 文本和选中
                     itemBinding.dropDownText.text = item.getShowText()
-                    itemBinding.root.setDebouncedClickListener {
-                        if (multiSelect && item.getChildren().isEmpty()) {
-                            item.setSelected(!item.isSelected())
-                            itemBinding.checkIv.isVisible = item.isSelected()
-                            val selected = binding.dropDownRv.models
-                                ?.filterIsInstance<TextDropDownEntity>()
-                                ?.filter { it.isSelected() }
-                            onMultiSelect(selected)
+                    itemBinding.rootLayout.setDebouncedClickListener {
+                        if (multiSelect) {
+                            if (item.getChildren().isEmpty()) {
+                                item.setSelected(!item.isSelected())
+                                itemBinding.checkIv.isVisible = item.isSelected()
+                                val selected = binding.dropDownRv.models
+                                    ?.filterIsInstance<TextDropDownEntity>()
+                                    ?.filter { it.isSelected() }
+                                onMultiSelect(selected)
+                            } else {
+                                if (item.itemExpand) collapse() else expand()
+                                itemBinding.arrowIv.rotation = if (item.itemExpand) 90f else 0f
+                            }
                         } else {
                             onSelect(item)
                             dialog?.dismiss()
@@ -83,6 +81,7 @@ class TextDropDownDialog(
                 onBind {
                     val item = getModel<TextDropDownEntity>()
                     val itemBinding = getBinding<ItemHomeTextDropDownBinding>()
+                    itemBinding.arrowIv.isVisible = false
                     itemBinding.dropDownText.text = item.getShowText()
                     itemBinding.checkIv.isVisible = item.isSelected()
                     itemBinding.root.setDebouncedClickListener {

+ 51 - 24
app/src/main/java/com/grkj/iscs/features/main/fragment/exception_manage/ExceptionReportFragment.kt

@@ -8,7 +8,9 @@ import com.grkj.iscs.features.main.dialog.TextDropDownDialog
 import com.grkj.iscs.features.main.viewmodel.exception_manage.ExceptionViewModel
 import com.grkj.ui_base.base.BaseFormFragment
 import com.grkj.ui_base.base.BaseFragment
+import com.grkj.ui_base.dialog.TipDialog
 import com.sik.sikcore.extension.setDebouncedClickListener
+import com.sik.sikcore.extension.toJson
 import dagger.hilt.android.AndroidEntryPoint
 
 /**
@@ -45,6 +47,20 @@ class ExceptionReportFragment : BaseFormFragment<FragmentExceptionReportBinding>
                 navController.popBackStack()
             }
         }
+        binding.confirm.setDebouncedClickListener {
+            viewModel.exceptionReport().observe(this) {
+                TipDialog.showSuccess(
+                    msg = getString(R.string.exception_report_success),
+                    onConfirmClick = {
+                        clearData()
+                        resetFormDirty()
+                    },
+                    onCancelClick = {
+                        clearData()
+                        resetFormDirty()
+                    })
+            }
+        }
         binding.exceptionType.setDebouncedClickListener {
             TextDropDownDialog.showSingle(viewModel.exceptionType.map {
                 TextDropDownDialog.SimpleTextDropDownEntity(
@@ -58,32 +74,32 @@ class ExceptionReportFragment : BaseFormFragment<FragmentExceptionReportBinding>
         }
         binding.exceptionSource.setDebouncedClickListener {
             if (viewModel.selectedExceptionType == viewModel.exceptionType.find { it.dictLabel == "硬件异常" }?.dictValue) {
-                viewModel.getExceptionSourceData().observe(this) {
-                    TextDropDownDialog.showMultiTree(viewModel.exceptionSourceData.map {
-                        TextDropDownDialog.SimpleTextDropDownEntity(
-                            dataText = it.sourceDataText,
-                            dataObject = it
-                        )
-                            .apply {
-                                setChildren(it.children.map {
-                                    TextDropDownDialog.SimpleTextDropDownEntity(
-                                        dataId = it.sourceDataId,
-                                        dataText = it.sourceDataText,
-                                        dataObject = it
-                                    ).apply {
-                                        setSelected(viewModel.selectedSourceData.map { it.sourceDataText }
-                                            .contains(it.sourceDataText))
-                                    }
-                                })
-                            }
-                    }, binding.exceptionSource) { selectedData ->
-                        binding.exceptionType.text =
-                            selectedData?.joinToString(",") { it.getShowText() }
-                        selectedData?.let {
-                            viewModel.selectedSourceData =
-                                it.map { it.getData() as ExceptionSourceDataEntity } as MutableList<ExceptionSourceDataEntity>
+                TextDropDownDialog.showMultiTree(viewModel.exceptionSourceData.map {
+                    TextDropDownDialog.SimpleTextDropDownEntity(
+                        dataText = it.sourceDataText,
+                        dataObject = it
+                    )
+                        .apply {
+                            setChildren(it.children.map {
+                                TextDropDownDialog.SimpleTextDropDownEntity(
+                                    dataId = it.sourceDataId,
+                                    dataText = it.sourceDataText,
+                                    dataObject = it,
+                                    dataLevel = 1
+                                ).apply {
+                                    setSelected(viewModel.selectedSourceData.map { it.sourceDataText }
+                                        .contains(getShowText()))
+                                }
+                            })
                         }
+                }, binding.exceptionSource) { selectedData ->
+                    binding.exceptionSource.text =
+                        selectedData?.joinToString(",") { it.getShowText() }
+                    selectedData?.let {
+                        viewModel.selectedSourceData =
+                            it.map { it.getData() as ExceptionSourceDataEntity } as MutableList<ExceptionSourceDataEntity>
                     }
+                    logger.info("选中的数据源:${viewModel.selectedSourceData.toJson()}")
                 }
             } else {
                 TextDropDownDialog.showSingle(viewModel.exceptionSourceData.map {
@@ -122,6 +138,17 @@ class ExceptionReportFragment : BaseFormFragment<FragmentExceptionReportBinding>
         }
     }
 
+    private fun clearData(){
+        viewModel.selectedExceptionType = null
+        viewModel.selectedExceptionDescription.clear()
+        viewModel.selectedSourceData.clear()
+        viewModel.selectedProcessApplication = null
+        binding.exceptionType.text = ""
+        binding.exceptionSource.text = ""
+        binding.exceptionDescription.text = ""
+        binding.processApplication.text = ""
+    }
+
     override fun initData() {
         super.initData()
         viewModel.getDictData().observe(this) {}

+ 2 - 0
app/src/main/java/com/grkj/iscs/features/main/fragment/job_manage/JobManageFragment.kt

@@ -131,6 +131,8 @@ class JobManageFragment : BaseFragment<FragmentJobManageBinding>() {
                 PopTip.tip(R.string.job_canceled)
             } else if (item.ticketStatus == JobTicketStatusEnum.FINISHED.status) {
                 PopTip.tip(R.string.job_finished)
+            } else if (item.exStatus == viewModel.jobTicketStatus.find { it.dictLabel == "异常" }?.dictValue?.toInt()) {
+                navController.navigate(R.id.action_jobManageFragment_to_exceptionJobFragment)
             } else {
                 navController.navigate(R.id.action_jobManageFragment_to_jobExecuteFragment)
             }

+ 101 - 7
app/src/main/java/com/grkj/iscs/features/main/viewmodel/exception_manage/ExceptionViewModel.kt

@@ -3,6 +3,8 @@ package com.grkj.iscs.features.main.viewmodel.exception_manage
 import androidx.lifecycle.LiveData
 import androidx.lifecycle.liveData
 import com.grkj.data.data.DictConstants
+import com.grkj.data.model.dos.IsExceptionSourceStandard
+import com.grkj.data.model.dos.IsExceptionStandard
 import com.grkj.data.model.res.CommonDictRes
 import com.grkj.iscs.features.main.entity.ExceptionSourceDataEntity
 import com.grkj.data.model.vo.IsExceptionStandardVo
@@ -13,6 +15,7 @@ import com.grkj.iscs.R
 import com.grkj.ui_base.base.BaseViewModel
 import com.grkj.ui_base.business.DataBusiness
 import com.grkj.ui_base.utils.CommonUtils
+import com.sik.sikcore.extension.toJson
 import dagger.hilt.android.lifecycle.HiltViewModel
 import kotlinx.coroutines.Dispatchers
 import javax.inject.Inject
@@ -26,6 +29,26 @@ class ExceptionViewModel @Inject constructor(
     val hardwareRepository: IHardwareRepository,
     val jobTicketRepository: IJobTicketRepository
 ) : BaseViewModel() {
+    /**
+     * 钥匙状态
+     */
+    var keyStatus: List<CommonDictRes> = mutableListOf()
+
+    /**
+     * 挂锁状态
+     */
+    var lockStatus: List<CommonDictRes> = mutableListOf()
+
+    /**
+     * 仓位状态
+     */
+    var slotsStatus: List<CommonDictRes> = mutableListOf()
+
+    /**
+     * 作业状态
+     */
+    var jobTicketStatus: List<CommonDictRes> = mutableListOf()
+
     /**
      * 异常类型
      */
@@ -80,6 +103,10 @@ class ExceptionViewModel @Inject constructor(
      */
     fun getDictData(): LiveData<Boolean> {
         return liveData(Dispatchers.IO) {
+            keyStatus = DataBusiness.fetchDict(DictConstants.KEY_KEY_STATUS)
+            lockStatus = DataBusiness.fetchDict(DictConstants.KEY_PAD_LOCK_STATUS)
+            slotsStatus = DataBusiness.fetchDict(DictConstants.KEY_SLOT_STATUS)
+            jobTicketStatus = DataBusiness.fetchDict(DictConstants.KEY_JOB_TICKET_STATUS)
             exceptionType = DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_TYPE)
             exceptionStatus = DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_STATUS)
             exceptionSourceDataType =
@@ -194,7 +221,7 @@ class ExceptionViewModel @Inject constructor(
             exceptionSourceData.clear()
             when (selectedExceptionType) {
                 //异常硬件
-                "0" -> {
+                exceptionType.find { it.dictLabel == "硬件异常" }?.dictValue -> {
                     val keyData = hardwareRepository.getAllKeyInfo()
                     keyData.map {
                         val exceptionSourceDataEntity =
@@ -203,7 +230,7 @@ class ExceptionViewModel @Inject constructor(
                         exceptionSourceDataEntity.sourceDataId = it.keyId
                         exceptionSourceDataEntity.sourceDataType =
                             exceptionSourceDataType.find { it.dictLabel == "钥匙" }?.dictValue?.toInt()
-                                ?: 2
+                                ?: 0
                         exceptionSourceDataEntity
                     }.toMutableList().let {
                         val exceptionSourceDataEntity =
@@ -211,7 +238,7 @@ class ExceptionViewModel @Inject constructor(
                         exceptionSourceDataEntity.sourceDataText = "钥匙"
                         exceptionSourceDataEntity.sourceDataType =
                             exceptionSourceDataType.find { it.dictLabel == "钥匙" }?.dictValue?.toInt()
-                                ?: 2
+                                ?: 0
                         exceptionSourceDataEntity.children = it
                         exceptionSourceData.add(exceptionSourceDataEntity)
                     }
@@ -223,7 +250,7 @@ class ExceptionViewModel @Inject constructor(
                         exceptionSourceDataEntity.sourceDataId = it.lockId
                         exceptionSourceDataEntity.sourceDataType =
                             exceptionSourceDataType.find { it.dictLabel == "挂锁" }?.dictValue?.toInt()
-                                ?: 2
+                                ?: 1
                         exceptionSourceDataEntity
                     }.toMutableList().let {
                         val exceptionSourceDataEntity =
@@ -231,7 +258,7 @@ class ExceptionViewModel @Inject constructor(
                         exceptionSourceDataEntity.sourceDataText = "挂锁"
                         exceptionSourceDataEntity.sourceDataType =
                             exceptionSourceDataType.find { it.dictLabel == "挂锁" }?.dictValue?.toInt()
-                                ?: 2
+                                ?: 1
                         exceptionSourceDataEntity.children = it
                         exceptionSourceData.add(exceptionSourceDataEntity)
                     }
@@ -239,7 +266,8 @@ class ExceptionViewModel @Inject constructor(
                     slotsData.map {
                         val exceptionSourceDataEntity =
                             ExceptionSourceDataEntity(itemGroupPosition = 1)
-                        exceptionSourceDataEntity.sourceDataText = "仓位${it.row + 1}-${it.col}"
+                        exceptionSourceDataEntity.sourceDataText =
+                            "仓位${it.row?.toInt()?.plus(1)}-${it.col}"
                         exceptionSourceDataEntity.sourceDataId = it.slotId
                         exceptionSourceDataEntity.sourceDataType =
                             exceptionSourceDataType.find { it.dictLabel == "仓位" }?.dictValue?.toInt()
@@ -257,7 +285,7 @@ class ExceptionViewModel @Inject constructor(
                     }
                 }
                 //异常作业
-                "1" -> {
+                exceptionType.find { it.dictLabel == "作业异常" }?.dictValue -> {
                     val jobTicketData = jobTicketRepository.getAllInProgressJob()
                     exceptionSourceData = jobTicketData.map {
                         val exceptionSourceDataEntity =
@@ -271,6 +299,72 @@ class ExceptionViewModel @Inject constructor(
                     }.toMutableList()
                 }
             }
+            logger.info("异常源:${exceptionSourceData.toJson()}")
+            emit(true)
+        }
+    }
+
+    /**
+     * 异常上报
+     */
+    fun exceptionReport(): LiveData<Boolean> {
+        return liveData(Dispatchers.IO) {
+
+            val exceptionData = IsExceptionStandard()
+            exceptionData.exceptionType = selectedExceptionType?.toInt() ?: 0
+            exceptionData.exceptionDescription = selectedExceptionDescription
+            exceptionData.processApplication = selectedProcessApplication
+            val exceptionId = exceptionRepository.reportException(exceptionData)
+            for (exceptionSource in selectedSourceData) {
+                when (exceptionSource.sourceDataType) {
+                    exceptionSourceDataType.find { it.dictLabel == "钥匙" }?.dictValue?.toInt() -> {
+                        val keyInfo =
+                            hardwareRepository.getKeyInfoByKeyId(exceptionSource.sourceDataId)
+                        keyInfo?.exStatus = keyStatus.find { it.dictLabel == "异常" }?.dictValue
+                        keyInfo?.remark = selectedExceptionDescription.joinToString(",")
+                        keyInfo?.let {
+                            hardwareRepository.updateKeyInfo(it)
+                        }
+                    }
+
+                    exceptionSourceDataType.find { it.dictLabel == "挂锁" }?.dictValue?.toInt() -> {
+                        val lockInfo =
+                            hardwareRepository.getLockInfoByLockId(exceptionSource.sourceDataId)
+                        lockInfo?.exStatus = lockStatus.find { it.dictLabel == "异常" }?.dictValue
+                        lockInfo?.remark = selectedExceptionDescription.joinToString(",")
+                        lockInfo?.let {
+                            hardwareRepository.updateLockInfo(it)
+                        }
+                    }
+
+                    exceptionSourceDataType.find { it.dictLabel == "仓位" }?.dictValue?.toInt() -> {
+                        val slotsInfo =
+                            hardwareRepository.getIsLockCabinetSlotBySlotId(exceptionSource.sourceDataId)
+                        slotsInfo?.status = slotsStatus.find { it.dictLabel == "异常" }?.dictValue
+                        slotsInfo?.remark = selectedExceptionDescription.joinToString(",")
+                        slotsInfo?.let {
+                            hardwareRepository.updateSlotsInfo(it)
+                        }
+                    }
+
+                    exceptionSourceDataType.find { it.dictLabel == "作业" }?.dictValue?.toInt() -> {
+                        val jobTicketData =
+                            jobTicketRepository.getTicketRawDataByTicketId(exceptionSource.sourceDataId)
+                        jobTicketData?.exStatus =
+                            jobTicketStatus.find { it.dictLabel == "异常" }?.dictValue?.toInt()
+                        jobTicketData?.remark = selectedExceptionDescription.joinToString(",")
+                        jobTicketData?.let {
+                            jobTicketRepository.updateTicketData(it)
+                        }
+                    }
+                }
+                val exceptionSourceData = IsExceptionSourceStandard()
+                exceptionSourceData.exceptionId = exceptionId
+                exceptionSourceData.sourceDataId = exceptionSource.sourceDataId
+                exceptionSourceData.sourceDataType = exceptionSource.sourceDataType
+                exceptionRepository.saveExceptionSourceData(exceptionSourceData)
+            }
+            emit(true)
         }
     }
 }

+ 2 - 0
app/src/main/java/com/grkj/iscs/features/main/viewmodel/job_manage/JobManageViewModel.kt

@@ -20,6 +20,7 @@ import kotlinx.coroutines.Dispatchers
 class JobManageViewModel @Inject constructor(
     val jobTicketRepository: IJobTicketRepository,
 ) : BaseViewModel() {
+    var jobTicketStatus: List<CommonDictRes> = mutableListOf()
     var jobManageDataList: MutableList<JobTicketManageVo> = mutableListOf()
     private var current: Int = 0
     private var size: Int = 50
@@ -46,6 +47,7 @@ class JobManageViewModel @Inject constructor(
             jobManageDataList.clear()
         }
         return liveData(Dispatchers.IO) {
+            jobTicketStatus = DataBusiness.fetchDict(DictConstants.KEY_JOB_TICKET_STATUS)
             jobManageDataList.addAll(jobTicketRepository.getJobDataPage(current, size))
             emit(true)
         }

+ 2 - 1
app/src/main/res/layout/fragment_exception_report.xml

@@ -213,7 +213,8 @@
             android:layout_height="wrap_content"
             android:gravity="right"
             android:orientation="horizontal"
-            android:padding="@dimen/common_spacing">
+            android:paddingHorizontal="@dimen/common_spacing_2x"
+            android:paddingVertical="@dimen/common_spacing">
 
             <TextView
                 android:id="@+id/confirm"

+ 3 - 0
app/src/main/res/navigation/nav_job_manage.xml

@@ -120,6 +120,9 @@
         <action
             android:id="@+id/action_jobManageFragment_to_jobExecuteFragment"
             app:destination="@id/jobExecuteFragment" />
+        <action
+            android:id="@+id/action_jobManageFragment_to_exceptionJobFragment"
+            app:destination="@+id/exceptionJobFragment" />
         <action
             android:id="@+id/action_jobManageFragment_to_editJobFragment"
             app:destination="@id/editJobFragment" />

+ 15 - 0
data/src/main/java/com/grkj/data/dao/ExceptionDao.kt

@@ -1,9 +1,12 @@
 package com.grkj.data.dao
 
 import androidx.room.Dao
+import androidx.room.Insert
+import androidx.room.OnConflictStrategy
 import androidx.room.Query
 import androidx.room.Transaction
 import androidx.room.Update
+import com.grkj.data.model.dos.IsExceptionSourceStandard
 import com.grkj.data.model.dos.IsExceptionStandard
 import com.grkj.data.model.vo.IsExceptionStandardVo
 
@@ -31,4 +34,16 @@ interface ExceptionDao {
     @Transaction
     @Query("select * from is_exception_standard where exception_id = :exceptionId")
     fun getExceptionDataById(exceptionId: Long): IsExceptionStandardVo?
+
+    /**
+     * 添加异常数据
+     */
+    @Insert(onConflict = OnConflictStrategy.REPLACE)
+    fun reportException(exceptionStandard: IsExceptionStandard): Long
+
+    /**
+     * 保存异常源数据
+     */
+    @Insert(onConflict = OnConflictStrategy.REPLACE)
+    fun saveExceptionSourceData(exceptionSourceData: IsExceptionSourceStandard)
 }

+ 6 - 0
data/src/main/java/com/grkj/data/dao/HardwareDao.kt

@@ -477,4 +477,10 @@ interface HardwareDao {
     @Query("select * from is_lock_cabinet_slots where slot_id = :slotId")
     fun getIsLockCabinetSlotBySlotId(slotId: Long): IsLockCabinetSlots?
 
+    /**
+     * 更新锁仓状态
+     */
+    @Update
+    fun updateSlotsInfo(slots: IsLockCabinetSlots)
+
 }

+ 12 - 0
data/src/main/java/com/grkj/data/dao/JobTicketDao.kt

@@ -452,4 +452,16 @@ interface JobTicketDao {
      */
     @Query("select * from is_job_ticket where ticket_status in ('1','2','3','4','7')")
     fun getAllInProgressJob(): List<IsJobTicket>
+
+    /**
+     * 根据作业id获取作业原始数据
+     */
+    @Query("select * from is_job_ticket where ticket_id = :ticketId")
+    fun getTicketRawDataByTicketId(ticketId: Long): IsJobTicket?
+
+    /**
+     * 更新作业数据
+     */
+    @Update
+    fun updateTicketData(ticket: IsJobTicket)
 }

+ 1 - 1
data/src/main/java/com/grkj/data/model/dos/IsExceptionSourceStandard.kt

@@ -10,7 +10,7 @@ open class IsExceptionSourceStandard : BaseBean() {
     var sourceId: Long = 0
 
     @ColumnInfo(name = "exception_id")
-    var exceptionId: Int? = null
+    var exceptionId: Long? = null
 
     @ColumnInfo(name = "source_data_id")
     var sourceDataId: Long = 0

+ 6 - 3
data/src/main/java/com/grkj/data/model/dos/IsExceptionStandard.kt

@@ -1,6 +1,8 @@
 package com.grkj.data.model.dos
 
 import androidx.room.*
+import com.grkj.data.data.MainDomainData
+import com.grkj.data.enums.CommonDictDataEnum
 import com.sik.sikcore.date.TimeUtils
 
 @Entity(tableName = "is_exception_standard")
@@ -14,16 +16,17 @@ class IsExceptionStandard : BaseBean() {
     var exceptionType: Int = 0
 
     @ColumnInfo(name = "exception_status")
-    var exceptionStatus: Int? = null
+    var exceptionStatus: Int? =
+        CommonDictDataEnum.EXCEPTION_STATUS.commonDictRes.find { it.dictLabel == "待处理" }?.dictValue?.toInt()
 
     @ColumnInfo(name = "exception_description")
-    var exceptionDescription: String? = null
+    var exceptionDescription: List<String>? = null
 
     @ColumnInfo(name = "process_application")
     var processApplication: String? = null
 
     @ColumnInfo(name = "reporter_id")
-    var reporterId: Long = 0L
+    var reporterId: Long = MainDomainData.userInfo?.userId ?: 0
 
     @ColumnInfo(name = "occurrence_time")
     var occurrenceTime: String? = TimeUtils.nowString(TimeUtils.DEFAULT_DATE_HOUR_MIN_SEC_FORMAT)

+ 12 - 0
data/src/main/java/com/grkj/data/repository/IExceptionRepository.kt

@@ -1,5 +1,7 @@
 package com.grkj.data.repository
 
+import com.grkj.data.model.dos.IsExceptionSourceStandard
+import com.grkj.data.model.dos.IsExceptionStandard
 import com.grkj.data.model.vo.IsExceptionStandardVo
 
 /**
@@ -25,4 +27,14 @@ interface IExceptionRepository {
      * 根据异常id获取异常数据
      */
     fun getExceptionDataById(exceptionId: Long): IsExceptionStandardVo?
+
+    /**
+     * 上报异常
+     */
+    fun reportException(exceptionData: IsExceptionStandard): Long
+
+    /**
+     * 保存异常源数据
+     */
+    fun saveExceptionSourceData(exceptionSourceData: IsExceptionSourceStandard)
 }

+ 5 - 0
data/src/main/java/com/grkj/data/repository/IHardwareRepository.kt

@@ -340,4 +340,9 @@ interface IHardwareRepository {
      * 获取所有挂锁数据
      */
     fun getAllLockInfo(): List<IsLock>
+
+    /**
+     * 更新锁仓状态
+     */
+    fun updateSlotsInfo(slots: IsLockCabinetSlots)
 }

+ 10 - 0
data/src/main/java/com/grkj/data/repository/IJobTicketRepository.kt

@@ -81,6 +81,16 @@ interface IJobTicketRepository {
      */
     fun getTicketDataByTicketId(ticketId: Long): JobTicketManageVo?
 
+    /**
+     * 根据作业id获取作业原始数据
+     */
+    fun getTicketRawDataByTicketId(ticketId: Long): IsJobTicket?
+
+    /**
+     * 更新作业
+     */
+    fun updateTicketData(isJobTicket: IsJobTicket)
+
     /**
      * 根据作业id获取点位数据
      */

+ 10 - 0
data/src/main/java/com/grkj/data/repository/impl/network/NetworkExceptionRepository.kt

@@ -1,5 +1,7 @@
 package com.grkj.data.repository.impl.network
 
+import com.grkj.data.model.dos.IsExceptionSourceStandard
+import com.grkj.data.model.dos.IsExceptionStandard
 import com.grkj.data.model.vo.IsExceptionStandardVo
 import com.grkj.data.repository.BaseRepository
 import com.grkj.data.repository.IExceptionRepository
@@ -26,4 +28,12 @@ class NetworkExceptionRepository @Inject constructor() : BaseRepository(), IExce
     override fun getExceptionDataById(exceptionId: Long): IsExceptionStandardVo? {
         TODO("Not yet implemented")
     }
+
+    override fun reportException(exceptionData: IsExceptionStandard): Long {
+        TODO("Not yet implemented")
+    }
+
+    override fun saveExceptionSourceData(exceptionSourceData: IsExceptionSourceStandard) {
+        TODO("Not yet implemented")
+    }
 }

+ 4 - 0
data/src/main/java/com/grkj/data/repository/impl/network/NetworkHardwareRepository.kt

@@ -307,4 +307,8 @@ class NetworkHardwareRepository  @Inject constructor() : BaseRepository(), IHard
     override fun getAllLockInfo(): List<IsLock> {
         TODO("Not yet implemented")
     }
+
+    override fun updateSlotsInfo(slots: IsLockCabinetSlots) {
+        TODO("Not yet implemented")
+    }
 }

+ 8 - 0
data/src/main/java/com/grkj/data/repository/impl/network/NetworkJobTicketRepository.kt

@@ -83,6 +83,14 @@ class NetworkJobTicketRepository  @Inject constructor() : BaseRepository(), IJob
         TODO("Not yet implemented")
     }
 
+    override fun getTicketRawDataByTicketId(ticketId: Long): IsJobTicket? {
+        TODO("Not yet implemented")
+    }
+
+    override fun updateTicketData(isJobTicket: IsJobTicket) {
+        TODO("Not yet implemented")
+    }
+
     override fun getTicketPointsByTicketId(ticketId: Long): List<PointManageVo> {
         TODO("Not yet implemented")
     }

+ 9 - 0
data/src/main/java/com/grkj/data/repository/impl/standard/ExceptionRepository.kt

@@ -4,6 +4,7 @@ import com.grkj.data.dao.ExceptionDao
 import com.grkj.data.dao.JobTicketDao
 import com.grkj.data.enums.CommonDictDataEnum
 import com.grkj.data.enums.JobTicketStatusEnum
+import com.grkj.data.model.dos.IsExceptionSourceStandard
 import com.grkj.data.model.dos.IsExceptionStandard
 import com.grkj.data.model.vo.IsExceptionStandardVo
 import com.grkj.data.repository.BaseRepository
@@ -77,4 +78,12 @@ class ExceptionRepository @Inject constructor(
     override fun getExceptionDataById(exceptionId: Long): IsExceptionStandardVo? {
         return exceptionDao.getExceptionDataById(exceptionId)
     }
+
+    override fun reportException(exceptionData: IsExceptionStandard): Long {
+        return exceptionDao.reportException(exceptionData)
+    }
+
+    override fun saveExceptionSourceData(exceptionSourceData: IsExceptionSourceStandard) {
+        exceptionDao.saveExceptionSourceData(exceptionSourceData)
+    }
 }

+ 4 - 0
data/src/main/java/com/grkj/data/repository/impl/standard/HardwareRepository.kt

@@ -506,4 +506,8 @@ class HardwareRepository @Inject constructor(
     override fun getAllLockInfo(): List<IsLock> {
         return hardwareDao.getAllLockData()
     }
+
+    override fun updateSlotsInfo(slots: IsLockCabinetSlots) {
+        return hardwareDao.updateSlotsInfo(slots)
+    }
 }

+ 8 - 0
data/src/main/java/com/grkj/data/repository/impl/standard/JobTicketRepository.kt

@@ -283,6 +283,14 @@ class JobTicketRepository @Inject constructor(
         return jobTicketDao.getTicketDataByTicketId(ticketId)
     }
 
+    override fun getTicketRawDataByTicketId(ticketId: Long): IsJobTicket? {
+        return jobTicketDao.getTicketRawDataByTicketId(ticketId)
+    }
+
+    override fun updateTicketData(isJobTicket: IsJobTicket) {
+        jobTicketDao.updateTicketData(isJobTicket)
+    }
+
     override fun getTicketPointsByTicketId(ticketId: Long): List<PointManageVo> {
         return jobTicketDao.getTicketPointsByTicketId(ticketId)
     }