|
@@ -137,31 +137,15 @@ class JobExecuteViewModel @Inject constructor(
|
|
|
*/
|
|
*/
|
|
|
fun cancelJob(): LiveData<Boolean> {
|
|
fun cancelJob(): LiveData<Boolean> {
|
|
|
return liveData(Dispatchers.IO) {
|
|
return liveData(Dispatchers.IO) {
|
|
|
- val ticketDetail = RepositoryManager.jobTicketRepo.getTicketDetail(ticketId)
|
|
|
|
|
- val workflowStep = workflowSteps.find { it.stepId == currentStepData?.workflowStepId }
|
|
|
|
|
- val role = ticketDetail?.ticketUserVOList?.find {
|
|
|
|
|
- it.userId == MainDomainData.userInfo?.userId && workflowStep?.currentUserCanConfirm() == true
|
|
|
|
|
- }
|
|
|
|
|
- if (role == null) {
|
|
|
|
|
|
|
+ if (ticketData?.createBy != MainDomainData.userInfo?.userName) {
|
|
|
ThreadUtils.runOnMain {
|
|
ThreadUtils.runOnMain {
|
|
|
PopTip.build()
|
|
PopTip.build()
|
|
|
.tip(CommonUtils.getStr(com.grkj.ui_base.R.string.no_permission_to_handle))
|
|
.tip(CommonUtils.getStr(com.grkj.ui_base.R.string.no_permission_to_handle))
|
|
|
}
|
|
}
|
|
|
return@liveData
|
|
return@liveData
|
|
|
}
|
|
}
|
|
|
- if (workflowStep?.needCheckFace() == true) {
|
|
|
|
|
- _uiEvents.send(UiEvent.FaceCheck)
|
|
|
|
|
- val checkResult = _paramResponse.receive() as Boolean
|
|
|
|
|
- if (checkResult) {
|
|
|
|
|
- jobTicketRepository.cancelJob(ticketId)
|
|
|
|
|
- emit(true)
|
|
|
|
|
- } else {
|
|
|
|
|
- emit(false)
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- jobTicketRepository.cancelJob(ticketId)
|
|
|
|
|
- emit(true)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ jobTicketRepository.cancelJob(ticketId)
|
|
|
|
|
+ emit(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -170,32 +154,15 @@ class JobExecuteViewModel @Inject constructor(
|
|
|
*/
|
|
*/
|
|
|
fun finishJob(): LiveData<Boolean> {
|
|
fun finishJob(): LiveData<Boolean> {
|
|
|
return liveData(Dispatchers.IO) {
|
|
return liveData(Dispatchers.IO) {
|
|
|
- val ticketDetail = RepositoryManager.jobTicketRepo.getTicketDetail(ticketId)
|
|
|
|
|
- val workflowStep = workflowSteps.find { it.stepId == currentStepData?.workflowStepId }
|
|
|
|
|
- ?: workflowSteps.last()
|
|
|
|
|
- val role = ticketDetail?.ticketUserVOList?.find {
|
|
|
|
|
- it.userId == MainDomainData.userInfo?.userId
|
|
|
|
|
- }
|
|
|
|
|
- if (role == null) {
|
|
|
|
|
|
|
+ if (ticketData?.createBy != MainDomainData.userInfo?.userName) {
|
|
|
ThreadUtils.runOnMain {
|
|
ThreadUtils.runOnMain {
|
|
|
PopTip.build()
|
|
PopTip.build()
|
|
|
.tip(CommonUtils.getStr(com.grkj.ui_base.R.string.no_permission_to_handle))
|
|
.tip(CommonUtils.getStr(com.grkj.ui_base.R.string.no_permission_to_handle))
|
|
|
}
|
|
}
|
|
|
return@liveData
|
|
return@liveData
|
|
|
}
|
|
}
|
|
|
- if (workflowStep?.needCheckFace() == true) {
|
|
|
|
|
- _uiEvents.send(UiEvent.FaceCheck)
|
|
|
|
|
- val checkResult = _paramResponse.receive() as Boolean
|
|
|
|
|
- if (checkResult) {
|
|
|
|
|
- jobTicketRepository.finishJob(ticketId)
|
|
|
|
|
- emit(true)
|
|
|
|
|
- } else {
|
|
|
|
|
- emit(false)
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- jobTicketRepository.finishJob(ticketId)
|
|
|
|
|
- emit(true)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ jobTicketRepository.finishJob(ticketId)
|
|
|
|
|
+ emit(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -219,19 +186,21 @@ class JobExecuteViewModel @Inject constructor(
|
|
|
val rfid = ModbusBusinessManager.getWaitTakeDeviceByTicketId(
|
|
val rfid = ModbusBusinessManager.getWaitTakeDeviceByTicketId(
|
|
|
DeviceConst.DEVICE_TYPE_KEY, ticketId
|
|
DeviceConst.DEVICE_TYPE_KEY, ticketId
|
|
|
)?.nfc
|
|
)?.nfc
|
|
|
- rfid?.let {
|
|
|
|
|
- val keyMac = ModbusBusinessManager.getKeyMacByRfid(it)
|
|
|
|
|
|
|
+ if (rfid != null) {
|
|
|
|
|
+ val keyMac = ModbusBusinessManager.getKeyMacByRfid(rfid)
|
|
|
ModbusBusinessManager.checkTicketAndSendTicket(keyMac)
|
|
ModbusBusinessManager.checkTicketAndSendTicket(keyMac)
|
|
|
return@liveData
|
|
return@liveData
|
|
|
- } ?: run {
|
|
|
|
|
|
|
+ } else {
|
|
|
hideLoading()
|
|
hideLoading()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
val ticketDetail = RepositoryManager.jobTicketRepo.getTicketDetail(ticketId)
|
|
val ticketDetail = RepositoryManager.jobTicketRepo.getTicketDetail(ticketId)
|
|
|
val workflowStep = workflowSteps.find { it.stepId == currentStepData?.workflowStepId }
|
|
val workflowStep = workflowSteps.find { it.stepId == currentStepData?.workflowStepId }
|
|
|
- val role = ticketDetail?.ticketUserVOList?.find {
|
|
|
|
|
- it.userId == MainDomainData.userInfo?.userId && workflowStep?.currentUserCanConfirm() == true && it.groupId == groupId
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ val role =
|
|
|
|
|
+ ticketDetail?.ticketUserVOList?.filter { it.userRole == RoleEnum.JTLOCKER.roleKey }
|
|
|
|
|
+ ?.find {
|
|
|
|
|
+ it.userId == MainDomainData.userInfo?.userId && workflowStep?.currentUserCanConfirm() == true && it.groupId == groupId
|
|
|
|
|
+ }
|
|
|
if (role == null) {
|
|
if (role == null) {
|
|
|
ThreadUtils.runOnMain {
|
|
ThreadUtils.runOnMain {
|
|
|
PopTip.build()
|
|
PopTip.build()
|
|
@@ -338,19 +307,21 @@ class JobExecuteViewModel @Inject constructor(
|
|
|
val rfid = ModbusBusinessManager.getWaitTakeDeviceByTicketId(
|
|
val rfid = ModbusBusinessManager.getWaitTakeDeviceByTicketId(
|
|
|
DeviceConst.DEVICE_TYPE_KEY, ticketId
|
|
DeviceConst.DEVICE_TYPE_KEY, ticketId
|
|
|
)?.nfc
|
|
)?.nfc
|
|
|
- rfid?.let {
|
|
|
|
|
- val keyMac = ModbusBusinessManager.getKeyMacByRfid(it)
|
|
|
|
|
|
|
+ if (rfid != null) {
|
|
|
|
|
+ val keyMac = ModbusBusinessManager.getKeyMacByRfid(rfid)
|
|
|
ModbusBusinessManager.checkTicketAndSendTicket(keyMac)
|
|
ModbusBusinessManager.checkTicketAndSendTicket(keyMac)
|
|
|
return@liveData
|
|
return@liveData
|
|
|
- } ?: run {
|
|
|
|
|
|
|
+ } else {
|
|
|
hideLoading()
|
|
hideLoading()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
val ticketDetail = RepositoryManager.jobTicketRepo.getTicketDetail(ticketId)
|
|
val ticketDetail = RepositoryManager.jobTicketRepo.getTicketDetail(ticketId)
|
|
|
val workflowStep = workflowSteps.find { it.stepId == currentStepData?.workflowStepId }
|
|
val workflowStep = workflowSteps.find { it.stepId == currentStepData?.workflowStepId }
|
|
|
- val role = ticketDetail?.ticketUserVOList?.find {
|
|
|
|
|
- it.userId == MainDomainData.userInfo?.userId && workflowStep?.currentUserCanConfirm() == true && it.groupId == groupId
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ val role =
|
|
|
|
|
+ ticketDetail?.ticketUserVOList?.filter { it.userRole == RoleEnum.JTLOCKER.roleKey }
|
|
|
|
|
+ ?.find {
|
|
|
|
|
+ it.userId == MainDomainData.userInfo?.userId && workflowStep?.currentUserCanConfirm() == true && it.groupId == groupId
|
|
|
|
|
+ }
|
|
|
if (role == null) {
|
|
if (role == null) {
|
|
|
ThreadUtils.runOnMain {
|
|
ThreadUtils.runOnMain {
|
|
|
PopTip.build()
|
|
PopTip.build()
|