|
@@ -1,18 +1,305 @@
|
|
|
package com.grkj.iscs.features.main.fragment.exception_manage
|
|
package com.grkj.iscs.features.main.fragment.exception_manage
|
|
|
|
|
|
|
|
|
|
+import android.graphics.drawable.GradientDrawable
|
|
|
|
|
+import android.view.ViewGroup
|
|
|
|
|
+import android.widget.LinearLayout
|
|
|
|
|
+import androidx.core.view.isVisible
|
|
|
|
|
+import androidx.fragment.app.viewModels
|
|
|
|
|
+import com.drake.brv.BindingAdapter
|
|
|
|
|
+import com.drake.brv.annotaion.DividerOrientation
|
|
|
|
|
+import com.drake.brv.utils.dividerSpace
|
|
|
|
|
+import com.drake.brv.utils.grid
|
|
|
|
|
+import com.drake.brv.utils.linear
|
|
|
|
|
+import com.drake.brv.utils.models
|
|
|
|
|
+import com.drake.brv.utils.setup
|
|
|
|
|
+import com.grkj.data.enums.RoleEnum
|
|
|
|
|
+import com.grkj.data.model.dos.WorkflowStep
|
|
|
|
|
+import com.grkj.data.model.vo.IsJobTicketPointsDataVo
|
|
|
|
|
+import com.grkj.data.model.vo.IsJobTicketStepDataVo
|
|
|
|
|
+import com.grkj.data.model.vo.IsJobTicketUserDataVo
|
|
|
import com.grkj.iscs.R
|
|
import com.grkj.iscs.R
|
|
|
|
|
+import com.grkj.iscs.common.DataTransferConstants
|
|
|
import com.grkj.iscs.databinding.FragmentExceptionJobBinding
|
|
import com.grkj.iscs.databinding.FragmentExceptionJobBinding
|
|
|
|
|
+import com.grkj.iscs.databinding.ItemJobExecuteColockBinding
|
|
|
|
|
+import com.grkj.iscs.databinding.ItemJobExecutePointBinding
|
|
|
|
|
+import com.grkj.iscs.databinding.ItemJobExecuteStepBinding
|
|
|
|
|
+import com.grkj.iscs.features.main.viewmodel.exception_manage.ExceptionJobViewModel
|
|
|
import com.grkj.ui_base.base.BaseFragment
|
|
import com.grkj.ui_base.base.BaseFragment
|
|
|
|
|
+import com.grkj.ui_base.dialog.TipDialog
|
|
|
|
|
+import com.grkj.ui_base.utils.CommonUtils
|
|
|
|
|
+import com.grkj.ui_base.utils.extension.toggleExpandView
|
|
|
|
|
+import com.kongzue.dialogx.dialogs.PopTip
|
|
|
|
|
+import com.sik.sikcore.data.GlobalDataTempStore
|
|
|
|
|
+import com.sik.sikcore.extension.setDebouncedClickListener
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 异常作业界面
|
|
* 异常作业界面
|
|
|
*/
|
|
*/
|
|
|
class ExceptionJobFragment : BaseFragment<FragmentExceptionJobBinding>() {
|
|
class ExceptionJobFragment : BaseFragment<FragmentExceptionJobBinding>() {
|
|
|
|
|
+ private val viewModel: ExceptionJobViewModel by viewModels()
|
|
|
|
|
+ private var currentTab: Int = 0
|
|
|
override fun getLayoutId(): Int {
|
|
override fun getLayoutId(): Int {
|
|
|
return R.layout.fragment_exception_job
|
|
return R.layout.fragment_exception_job
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun initView() {
|
|
override fun initView() {
|
|
|
|
|
+ binding.back.setDebouncedClickListener {
|
|
|
|
|
+ if ((binding.dataLayout.parent as ViewGroup).id == binding.fullScreenRootLayout.id) {
|
|
|
|
|
+ binding.spaceView.isVisible = false
|
|
|
|
|
+ toggleExpandView(binding.fullScreenRootLayout, binding.dataLayout, true)
|
|
|
|
|
+ binding.fullScreen.isVisible = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ navController.popBackStack()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.listRv.linear().setup {
|
|
|
|
|
+ addType<IsJobTicketPointsDataVo>(R.layout.item_job_execute_point)
|
|
|
|
|
+ onBind {
|
|
|
|
|
+ onPointsRVListBinding(this)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.stepRv.linear(orientation = LinearLayout.HORIZONTAL).setup {
|
|
|
|
|
+ addType<IsJobTicketStepDataVo>(R.layout.item_job_execute_step)
|
|
|
|
|
+ onBind {
|
|
|
|
|
+ onStepRVListBinding(this)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.cancelException.setDebouncedClickListener {
|
|
|
|
|
+ viewModel.cancelException().observe(this) {
|
|
|
|
|
+ navController.popBackStack()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.handleException.setDebouncedClickListener {
|
|
|
|
|
+ viewModel.handleException().observe(this) {
|
|
|
|
|
+ navController.popBackStack()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.waitToColockRv.grid(3).dividerSpace(10, DividerOrientation.GRID).setup {
|
|
|
|
|
+ addType<IsJobTicketUserDataVo>(R.layout.item_job_execute_colock)
|
|
|
|
|
+ onBind {
|
|
|
|
|
+ onColockerRVListBinding(this)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ binding.alreadyColockRv.grid(3).dividerSpace(10, DividerOrientation.GRID).setup {
|
|
|
|
|
+ addType<IsJobTicketUserDataVo>(R.layout.item_job_execute_colock)
|
|
|
|
|
+ onBind {
|
|
|
|
|
+ onColockerRVListBinding(this)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ binding.alreadyUncolockRv.grid(3).dividerSpace(10, DividerOrientation.GRID).setup {
|
|
|
|
|
+ addType<IsJobTicketUserDataVo>(R.layout.item_job_execute_colock)
|
|
|
|
|
+ onBind {
|
|
|
|
|
+ onColockerRVListBinding(this)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.fullScreen.setDebouncedClickListener {
|
|
|
|
|
+ toggleExpandView(binding.fullScreenRootLayout, binding.dataLayout, false)
|
|
|
|
|
+ binding.fullScreen.isVisible = false
|
|
|
|
|
+ binding.spaceView.isVisible = true
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.descriptionTab.setDebouncedClickListener {
|
|
|
|
|
+ checkLayout(0)
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.lockerTab.setDebouncedClickListener {
|
|
|
|
|
+ checkLayout(1)
|
|
|
|
|
+ }
|
|
|
|
|
+ binding.colockerTab.setDebouncedClickListener {
|
|
|
|
|
+ checkLayout(2)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查界面
|
|
|
|
|
+ */
|
|
|
|
|
+ private fun checkLayout(index: Int) {
|
|
|
|
|
+ currentTab = index
|
|
|
|
|
+ binding.descriptionTab.isSelected = index == 0
|
|
|
|
|
+ binding.lockerTab.isSelected = index == 1
|
|
|
|
|
+ binding.colockerTab.isSelected = index == 2
|
|
|
|
|
+ binding.stepDescriptionTv.isVisible = index == 0
|
|
|
|
|
+ binding.lockStatusLayout.isVisible = index == 1
|
|
|
|
|
+ binding.colockerLayout.isVisible = index == 2
|
|
|
|
|
+ binding.dataTitleTv.text = when (index) {
|
|
|
|
|
+ 0 -> CommonUtils.getStr(
|
|
|
|
|
+ R.string.job_execute_step_description,
|
|
|
|
|
+ viewModel.workflowSteps.find { it.stepId == viewModel.currentStepData?.workflowStepId }?.stepTitle
|
|
|
|
|
+ ?: ""
|
|
|
|
|
+ ).toString()
|
|
|
|
|
+
|
|
|
|
|
+ 1 -> CommonUtils.getStr(R.string.job_execute_lock_status_title).toString()
|
|
|
|
|
+ 2 -> CommonUtils.getStr(R.string.job_execute_colocker_colock_status_title).toString()
|
|
|
|
|
+ else -> ""
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun BindingAdapter.BindingViewHolder.onStepRVListBinding(holder: BindingAdapter.BindingViewHolder) {
|
|
|
|
|
+ val itemBinding = holder.getBinding<ItemJobExecuteStepBinding>()
|
|
|
|
|
+ val item = holder.getModel<IsJobTicketStepDataVo>()
|
|
|
|
|
+ itemBinding.stepIconIv.setImageResource(getStepIcon(viewModel.workflowSteps.find { it.stepId == item.workflowStepId }))
|
|
|
|
|
+ itemBinding.stepNameTv.text =
|
|
|
|
|
+ viewModel.workflowSteps.find { it.stepId == item.workflowStepId }?.stepTitleShort
|
|
|
|
|
+ itemBinding.stepIndexTv.text = item.stepIndex.toString()
|
|
|
|
|
+ itemBinding.dividerIv.isVisible = item.stepId != viewModel.ticketStep.last().stepId
|
|
|
|
|
+ val bg = itemBinding.stepLayout.background
|
|
|
|
|
+ when (item.stepStatus) {
|
|
|
|
|
+ "1" -> {
|
|
|
|
|
+ if (bg is GradientDrawable) {
|
|
|
|
|
+ bg.mutate() // 拷贝一份,避免影响到其它引用了同一个 drawable 的 view
|
|
|
|
|
+ bg.setColor(requireContext().getColor(R.color.color_b2f2bb))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ "0" -> {
|
|
|
|
|
+ if (item.stepId == viewModel.currentStepData?.stepId) {
|
|
|
|
|
+ if (bg is GradientDrawable) {
|
|
|
|
|
+ bg.mutate() // 拷贝一份,避免影响到其它引用了同一个 drawable 的 view
|
|
|
|
|
+ bg.setColor(requireContext().getColor(R.color.color_ffec99))
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ itemBinding.stepLayout.backgroundTintList = null
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun onColockerRVListBinding(holder: BindingAdapter.BindingViewHolder) {
|
|
|
|
|
+ val itemBinding = holder.getBinding<ItemJobExecuteColockBinding>()
|
|
|
|
|
+ val item = holder.getModel<IsJobTicketUserDataVo>()
|
|
|
|
|
+ itemBinding.name.text = item.nickName
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun getStepIcon(workflowStep: WorkflowStep?): Int {
|
|
|
|
|
+ if (workflowStep == null) {
|
|
|
|
|
+ return 0
|
|
|
|
|
+ }
|
|
|
|
|
+ return when {
|
|
|
|
|
+ workflowStep.stepTitleShort?.contains(
|
|
|
|
|
+ CommonUtils.getStr(com.grkj.ui_base.R.string.recognize_work_content).toString()
|
|
|
|
|
+ ) == true -> R.mipmap.icon_loto_step_1
|
|
|
|
|
+
|
|
|
|
|
+ workflowStep.stepTitleShort?.contains(
|
|
|
|
|
+ CommonUtils.getStr(com.grkj.ui_base.R.string.power_isolation_way).toString()
|
|
|
|
|
+ ) == true -> R.mipmap.icon_loto_step_2
|
|
|
|
|
+
|
|
|
|
|
+ workflowStep.stepTitleShort?.contains(
|
|
|
|
|
+ CommonUtils.getStr(com.grkj.ui_base.R.string.shutdown).toString()
|
|
|
|
|
+ ) == true -> R.mipmap.icon_loto_step_4
|
|
|
|
|
+
|
|
|
|
|
+ workflowStep.stepTitleShort?.contains(
|
|
|
|
|
+ CommonUtils.getStr(com.grkj.ui_base.R.string.ensure_power_isolation).toString()
|
|
|
|
|
+ ) == true -> R.mipmap.icon_loto_step_6
|
|
|
|
|
+
|
|
|
|
|
+ workflowStep.stepTitleShort?.contains(
|
|
|
|
|
+ CommonUtils.getStr(com.grkj.ui_base.R.string.check_before_unlocking).toString()
|
|
|
|
|
+ ) == true -> R.mipmap.icon_loto_step_7
|
|
|
|
|
+
|
|
|
|
|
+ workflowStep.stepTitleShort?.contains(
|
|
|
|
|
+ CommonUtils.getStr(com.grkj.ui_base.R.string.unlock_and_restore_switch).toString()
|
|
|
|
|
+ ) == true -> R.mipmap.icon_loto_step_8
|
|
|
|
|
+
|
|
|
|
|
+ workflowStep.enableSetLocker || workflowStep.enableSetColocker -> R.mipmap.icon_step_select_member
|
|
|
|
|
+ workflowStep.enableLock -> R.mipmap.icon_step_lock
|
|
|
|
|
+ workflowStep.enableColock -> R.mipmap.icon_step_colock
|
|
|
|
|
+ workflowStep.enableUnlock -> R.mipmap.icon_step_unlock
|
|
|
|
|
+ else -> 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun BindingAdapter.BindingViewHolder.onPointsRVListBinding(holder: BindingAdapter.BindingViewHolder) {
|
|
|
|
|
+ val itemBinding = holder.getBinding<ItemJobExecutePointBinding>()
|
|
|
|
|
+ val item = holder.getModel<IsJobTicketPointsDataVo>()
|
|
|
|
|
+ itemBinding.pointName.text = item.pointName
|
|
|
|
|
+ itemBinding.pointFunction.text = item.pointFunction
|
|
|
|
|
+ itemBinding.lockStatusLayout.isVisible = item.pointStatus != "0"
|
|
|
|
|
+ if (item.pointStatus == "1") {
|
|
|
|
|
+ itemBinding.lockStatusLayout.setBackgroundResource(R.drawable.bg_btn_job_execute_go_locking)
|
|
|
|
|
+ itemBinding.lockStatusIv.setImageResource(R.drawable.icon_ticket_lock)
|
|
|
|
|
+ itemBinding.lockStatusTv.text =
|
|
|
|
|
+ requireContext().getText(com.grkj.ui_base.R.string.has_locked)
|
|
|
|
|
+ } else if (item.pointStatus == "2") {
|
|
|
|
|
+ itemBinding.lockStatusLayout.setBackgroundResource(R.drawable.bg_btn_job_execute_go_unlocking)
|
|
|
|
|
+ itemBinding.lockStatusIv.setImageResource(R.drawable.icon_ticket_unlock)
|
|
|
|
|
+ itemBinding.lockStatusTv.text =
|
|
|
|
|
+ requireContext().getText(com.grkj.ui_base.R.string.unlocked)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun initData() {
|
|
|
|
|
+ super.initData()
|
|
|
|
|
+ if (!GlobalDataTempStore.getInstance().hasData(DataTransferConstants.KEY_JOB_TICKET_ID)) {
|
|
|
|
|
+ PopTip.tip(R.string.job_lost)
|
|
|
|
|
+ navController.popBackStack()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!GlobalDataTempStore.getInstance().hasData(DataTransferConstants.KEY_EXCEPTION_ID)) {
|
|
|
|
|
+ PopTip.tip(R.string.exception_lost)
|
|
|
|
|
+ navController.popBackStack()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ viewModel.getWorkflowModes().observe(this) {
|
|
|
|
|
+ viewModel.ticketId = GlobalDataTempStore.getInstance()
|
|
|
|
|
+ .getData(DataTransferConstants.KEY_JOB_TICKET_ID) as Long
|
|
|
|
|
+ viewModel.exceptionId = GlobalDataTempStore.getInstance()
|
|
|
|
|
+ .getData(DataTransferConstants.KEY_EXCEPTION_ID) as Long
|
|
|
|
|
+ getData()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun getData() {
|
|
|
|
|
+ viewModel.getExceptionData().observe(this) {
|
|
|
|
|
+ binding.exceptionDescription.text =
|
|
|
|
|
+ viewModel.exceptionData?.exceptionDescription?.joinToString(",")
|
|
|
|
|
+ }
|
|
|
|
|
+ viewModel.getJobTicketData().observe(this) {
|
|
|
|
|
+ if (it) {
|
|
|
|
|
+ viewModel.isUnlockFirst(viewModel.ticketData?.modeId!!).observe(this) {}
|
|
|
|
|
+ viewModel.getWorkflowSteps(viewModel.ticketData?.modeId!!).observe(this) {
|
|
|
|
|
+ binding.exceptionJob.text = viewModel.ticketData!!.ticketName
|
|
|
|
|
+ binding.jobNameTv.text = getString(R.string.exception_job_title)
|
|
|
|
|
+ binding.listRv.models = viewModel.ticketPoints
|
|
|
|
|
+ binding.stepRv.models = viewModel.ticketStep
|
|
|
|
|
+ viewModel.currentStepData =
|
|
|
|
|
+ viewModel.ticketStep.firstOrNull { it.stepStatus == "0" }
|
|
|
|
|
+ binding.stepDescriptionTv.text =
|
|
|
|
|
+ viewModel.workflowSteps.find { it.stepId == viewModel.currentStepData?.workflowStepId }?.stepDescription
|
|
|
|
|
+ refreshTicketUser()
|
|
|
|
|
+ checkLayout(currentTab)
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ TipDialog.showError(
|
|
|
|
|
+ msg = CommonUtils.getStr(com.grkj.ui_base.R.string.ticket_lost).toString(),
|
|
|
|
|
+ onConfirmClick = {
|
|
|
|
|
+ navController.popBackStack()
|
|
|
|
|
+ },
|
|
|
|
|
+ onCancelClick = {
|
|
|
|
|
+ navController.popBackStack()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun refreshTicketUser() {
|
|
|
|
|
+ viewModel.ticketUser.let {
|
|
|
|
|
+ binding.waitToColockRv.models =
|
|
|
|
|
+ it.filter { it.jobStatus == "0" && it.userRole == RoleEnum.JTCOLOCKER.roleKey }
|
|
|
|
|
+ binding.waitToColock.text =
|
|
|
|
|
+ getString(
|
|
|
|
|
+ R.string.wait_to_colock,
|
|
|
|
|
+ it.count { it.jobStatus == "0" && it.userRole == RoleEnum.JTCOLOCKER.roleKey })
|
|
|
|
|
+ binding.alreadyColockRv.models =
|
|
|
|
|
+ it.filter { it.jobStatus == "1" && it.userRole == RoleEnum.JTCOLOCKER.roleKey }
|
|
|
|
|
+ binding.alreadyColock.text =
|
|
|
|
|
+ getString(
|
|
|
|
|
+ R.string.already_colock,
|
|
|
|
|
+ it.count { it.jobStatus == "1" && it.userRole == RoleEnum.JTCOLOCKER.roleKey })
|
|
|
|
|
+ binding.alreadyUncolockRv.models =
|
|
|
|
|
+ it.filter { it.jobStatus == "2" && it.userRole == RoleEnum.JTCOLOCKER.roleKey }
|
|
|
|
|
+ binding.alreadyUncolock.text =
|
|
|
|
|
+ getString(
|
|
|
|
|
+ R.string.already_uncolock,
|
|
|
|
|
+ it.count { it.jobStatus == "2" && it.userRole == RoleEnum.JTCOLOCKER.roleKey })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|