|
@@ -3,6 +3,7 @@ package com.grkj.iscs.features.main.viewmodel.exception_manage
|
|
|
import androidx.lifecycle.LiveData
|
|
import androidx.lifecycle.LiveData
|
|
|
import androidx.lifecycle.liveData
|
|
import androidx.lifecycle.liveData
|
|
|
import com.grkj.data.data.DictConstants
|
|
import com.grkj.data.data.DictConstants
|
|
|
|
|
+import com.grkj.data.enums.CommonDictDataEnum
|
|
|
import com.grkj.data.model.dos.IsExceptionSourceStandard
|
|
import com.grkj.data.model.dos.IsExceptionSourceStandard
|
|
|
import com.grkj.data.model.dos.IsExceptionStandard
|
|
import com.grkj.data.model.dos.IsExceptionStandard
|
|
|
import com.grkj.data.model.res.CommonDictRes
|
|
import com.grkj.data.model.res.CommonDictRes
|
|
@@ -70,9 +71,13 @@ class ExceptionViewModel @Inject constructor(
|
|
|
var exceptionDescription: List<CommonDictRes> = mutableListOf()
|
|
var exceptionDescription: List<CommonDictRes> = mutableListOf()
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 处理申请
|
|
|
|
|
|
|
+ * 处理申请(硬件)
|
|
|
*/
|
|
*/
|
|
|
- var processApplication: List<CommonDictRes> = mutableListOf()
|
|
|
|
|
|
|
+ var processApplicationHardware: List<CommonDictRes> = mutableListOf()
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理申请(作业)
|
|
|
|
|
+ */
|
|
|
|
|
+ var processApplicationJob: List<CommonDictRes> = mutableListOf()
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 异常数据
|
|
* 异常数据
|
|
@@ -112,8 +117,10 @@ class ExceptionViewModel @Inject constructor(
|
|
|
exceptionSourceDataType =
|
|
exceptionSourceDataType =
|
|
|
DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_SOURCE_TYPE)
|
|
DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_SOURCE_TYPE)
|
|
|
exceptionDescription = DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_DESCRIPTION)
|
|
exceptionDescription = DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_DESCRIPTION)
|
|
|
- processApplication =
|
|
|
|
|
- DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_PROCESS_APPLICATION)
|
|
|
|
|
|
|
+ processApplicationHardware =
|
|
|
|
|
+ DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_PROCESS_APPLICATION_HARDWARE)
|
|
|
|
|
+ processApplicationJob =
|
|
|
|
|
+ DataBusiness.fetchDict(DictConstants.KEY_EXCEPTION_PROCESS_APPLICATION_JOB)
|
|
|
emit(true)
|
|
emit(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -243,6 +250,7 @@ class ExceptionViewModel @Inject constructor(
|
|
|
//异常硬件
|
|
//异常硬件
|
|
|
exceptionType.find { it.dictLabel == "硬件异常" }?.dictValue -> {
|
|
exceptionType.find { it.dictLabel == "硬件异常" }?.dictValue -> {
|
|
|
val keyData = hardwareRepository.getAllKeyInfo()
|
|
val keyData = hardwareRepository.getAllKeyInfo()
|
|
|
|
|
+ .filter { it.exStatus.toString() != keyStatus.find { it.dictLabel == "异常" }?.dictValue }
|
|
|
keyData.map {
|
|
keyData.map {
|
|
|
val exceptionSourceDataEntity =
|
|
val exceptionSourceDataEntity =
|
|
|
ExceptionSourceDataEntity(itemGroupPosition = 1)
|
|
ExceptionSourceDataEntity(itemGroupPosition = 1)
|
|
@@ -263,6 +271,7 @@ class ExceptionViewModel @Inject constructor(
|
|
|
exceptionSourceData.add(exceptionSourceDataEntity)
|
|
exceptionSourceData.add(exceptionSourceDataEntity)
|
|
|
}
|
|
}
|
|
|
val lockData = hardwareRepository.getAllLockInfo()
|
|
val lockData = hardwareRepository.getAllLockInfo()
|
|
|
|
|
+ .filter { it.exStatus.toString() != lockStatus.find { it.dictLabel == "异常" }?.dictValue }
|
|
|
lockData.map {
|
|
lockData.map {
|
|
|
val exceptionSourceDataEntity =
|
|
val exceptionSourceDataEntity =
|
|
|
ExceptionSourceDataEntity(itemGroupPosition = 1)
|
|
ExceptionSourceDataEntity(itemGroupPosition = 1)
|
|
@@ -283,6 +292,7 @@ class ExceptionViewModel @Inject constructor(
|
|
|
exceptionSourceData.add(exceptionSourceDataEntity)
|
|
exceptionSourceData.add(exceptionSourceDataEntity)
|
|
|
}
|
|
}
|
|
|
val slotsData = hardwareRepository.getAllSlotsData()
|
|
val slotsData = hardwareRepository.getAllSlotsData()
|
|
|
|
|
+ .filter { it.status.toString() != slotsStatus.find { it.dictLabel == "异常" }?.dictValue }
|
|
|
slotsData.map {
|
|
slotsData.map {
|
|
|
val exceptionSourceDataEntity =
|
|
val exceptionSourceDataEntity =
|
|
|
ExceptionSourceDataEntity(itemGroupPosition = 1)
|
|
ExceptionSourceDataEntity(itemGroupPosition = 1)
|
|
@@ -307,6 +317,7 @@ class ExceptionViewModel @Inject constructor(
|
|
|
//异常作业
|
|
//异常作业
|
|
|
exceptionType.find { it.dictLabel == "作业异常" }?.dictValue -> {
|
|
exceptionType.find { it.dictLabel == "作业异常" }?.dictValue -> {
|
|
|
val jobTicketData = jobTicketRepository.getAllInProgressJob()
|
|
val jobTicketData = jobTicketRepository.getAllInProgressJob()
|
|
|
|
|
+ .filter { it.exStatus.toString() != jobTicketStatus.find { it.dictLabel == "异常" }?.dictValue }
|
|
|
exceptionSourceData = jobTicketData.map {
|
|
exceptionSourceData = jobTicketData.map {
|
|
|
val exceptionSourceDataEntity =
|
|
val exceptionSourceDataEntity =
|
|
|
ExceptionSourceDataEntity(itemGroupPosition = 0)
|
|
ExceptionSourceDataEntity(itemGroupPosition = 0)
|
|
@@ -333,56 +344,7 @@ class ExceptionViewModel @Inject constructor(
|
|
|
exceptionData.exceptionType = selectedExceptionType?.toInt() ?: 0
|
|
exceptionData.exceptionType = selectedExceptionType?.toInt() ?: 0
|
|
|
exceptionData.exceptionDescription = selectedExceptionDescription
|
|
exceptionData.exceptionDescription = selectedExceptionDescription
|
|
|
exceptionData.processApplication = selectedProcessApplication
|
|
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)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ exceptionRepository.reportException(exceptionData)
|
|
|
emit(true)
|
|
emit(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|