Explorar o código

1. 解决共锁人选择的问题
2. 获取钥匙允许强制获取一把钥匙

bjb hai 5 meses
pai
achega
9957aa54a3

+ 2 - 2
app/src/main/java/com/grkj/iscs_mars/view/fragment/JobProgressFragment.kt

@@ -115,7 +115,7 @@ class JobProgressFragment(val goBack: () -> Unit, val changePage: (PageChangeBO)
                         mTipDialog?.setType(TipDialog.TYPE_HINT)
                         mTipDialog?.setConfirmListener {
                             BusinessManager.sendLoadingEventMsg(getString(R.string.system_is_processing))
-                            presenter?.handleLockProcess(mPageChangeBO?.ticketId!!)
+                            presenter?.handleLockProcess(mPageChangeBO?.ticketId!!, true)
                         }
                         mTipDialog?.showCancelCountdown(10)
                     } else {
@@ -150,7 +150,7 @@ class JobProgressFragment(val goBack: () -> Unit, val changePage: (PageChangeBO)
                         }
                         mTipDialog?.showCancelCountdown(10)
                     } else {
-                        presenter?.getTicketDetail(mPageChangeBO?.ticketId!!){
+                        presenter?.getTicketDetail(mPageChangeBO?.ticketId!!) {
                             if (it?.ticketKeyVOList?.any { it.keyStatus != "2" && it.ticketType == 1 && it.collectTime != null && it.giveBackTime == null } == true) {
                                 if (mTipDialog == null) {
                                     mTipDialog = TipDialog(requireContext())

+ 39 - 43
app/src/main/java/com/grkj/iscs_mars/view/fragment/WorkerFragment.kt

@@ -160,12 +160,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
                         mCoLockerSelectedList.any { it.userId == user.userId && it.userRole == USER_ROLE_COLOCKER }
                     holder.setText(R.id.tv_name, user.nickName)
                     holder.setOnClickListener(R.id.root) {
-                        if (presenter?.colockerInsideCanAdd(
-                                requireContext(),
-                                user,
-                                mStep
-                            ) == true
-                        ) {
+                        if (presenter?.colockerInsideCanAdd(requireContext(), user, mStep) == true) {
                             val addUser = TicketUserReqVO(
                                 user.userId!!,
                                 user.nickName!!,
@@ -174,26 +169,24 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
                                 ticketUserVOList.find { ticketUser -> ticketUser.userId == user.userId }?.jobStatus
                             )
                             // 内部共锁人选择
-                            if (mCoLockerSelectedList.any { it.userId == user.userId } &&
-                                presenter?.colockerCanRemove(
-                                    requireContext(),
-                                    addUser,
-                                    mStep
-                                ) == true
-                            ) {
-                                val minColockerSize =
-                                    presenter?.getMinColockerSize(requireContext()) ?: 1
-                                if (mColockerSelectedShowList.size == minColockerSize) {
-                                    ToastUtils.tip(
-                                        getString(
-                                            R.string.keep_at_least_colocker,
-                                            minColockerSize
+                            if (mCoLockerSelectedList.any { it.userId == user.userId }) {
+                                if (presenter?.colockerCanRemove(requireContext(), addUser, mStep) == true) {
+                                    val minColockerSize =
+                                        presenter?.getMinColockerSize(requireContext()) ?: 1
+                                    if (mColockerSelectedShowList.size == minColockerSize) {
+                                        ToastUtils.tip(
+                                            getString(
+                                                R.string.keep_at_least_colocker,
+                                                minColockerSize
+                                            )
                                         )
-                                    )
-                                    return@setOnClickListener
+                                        return@setOnClickListener
+                                    }
+                                    mCoLockerSelectedList.removeIf { it.userId == user.userId }
+                                    mColockerSelectedShowList.removeIf { it.userId == user.userId }
+                                } else {
+                                    ToastUtils.tip(getString(R.string.can_not_remove_current_colocker))
                                 }
-                                mCoLockerSelectedList.removeIf { it.userId == user.userId }
-                                mColockerSelectedShowList.removeIf { it.userId == user.userId }
                             } else {
                                 mCoLockerSelectedList.add(addUser)
                                 mColockerSelectedShowList.add(addUser)
@@ -233,26 +226,29 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
                                 ticketUserVOList.find { ticketUser -> ticketUser.userId == user.userId }?.jobStatus
                             )
                             // 外部共锁人选择
-                            if (mCoLockerSelectedList.any { it.userId == user.userId } &&
-                                presenter?.colockerCanRemove(
-                                    requireContext(),
-                                    addUser,
-                                    mStep
-                                ) == true
-                            ) {
-                                val minColockerSize =
-                                    presenter?.getMinColockerSize(requireContext()) ?: 1
-                                if (mColockerSelectedShowList.size == minColockerSize) {
-                                    ToastUtils.tip(
-                                        getString(
-                                            R.string.keep_at_least_colocker,
-                                            minColockerSize
+                            if (mCoLockerSelectedList.any { it.userId == user.userId }) {
+                                if (presenter?.colockerCanRemove(
+                                        requireContext(),
+                                        addUser,
+                                        mStep
+                                    ) == true
+                                ) {
+                                    val minColockerSize =
+                                        presenter?.getMinColockerSize(requireContext()) ?: 1
+                                    if (mColockerSelectedShowList.size == minColockerSize) {
+                                        ToastUtils.tip(
+                                            getString(
+                                                R.string.keep_at_least_colocker,
+                                                minColockerSize
+                                            )
                                         )
-                                    )
-                                    return@setOnClickListener
+                                        return@setOnClickListener
+                                    }
+                                    mCoLockerSelectedList.removeIf { it.userId == user.userId }
+                                    mColockerSelectedShowList.removeIf { it.userId == user.userId }
+                                } else {
+                                    ToastUtils.tip(getString(R.string.can_not_remove_current_colocker))
                                 }
-                                mCoLockerSelectedList.removeIf { it.userId == user.userId }
-                                mColockerSelectedShowList.removeIf { it.userId == user.userId }
                             } else {
                                 mCoLockerSelectedList.add(addUser)
                                 mColockerSelectedShowList.add(addUser)
@@ -307,7 +303,7 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
                     mBinding?.layoutLocker?.root?.visibility = View.VISIBLE
                     mBinding?.layoutLocker?.tvName?.text = user.userName
                 }
-                mLockerSelectedList.add(
+                mCoLockerSelectedList.add(
                     TicketUserReqVO(
                         user.userId!!,
                         user.userName!!,

+ 6 - 2
app/src/main/java/com/grkj/iscs_mars/view/presenter/JobProgressPresenter.kt

@@ -108,8 +108,11 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
 
     /**
      * 上锁人上锁流程
+     *
+     * @param ticketId      当前作业票id
+     * @param forceGetKey   是否强制获取一把钥匙,默认false
      */
-    fun handleLockProcess(ticketId: Long) {
+    fun handleLockProcess(ticketId: Long, forceGetKey: Boolean = false) {
         SPUtils.resetTicketTakeLockException(ticketId)
         NetApi.checkBeforeAction(ticketId, true) {
             if (!it) {
@@ -143,9 +146,10 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
                         ToastUtils.tip(R.string.please_take_out_ready_device_first)
                     }
                     //是否需要钥匙,如果钥匙已经取出则无法再取钥匙
-                    val isNeedKey =
+                    var isNeedKey =
                         ticketDetail.ticketKeyVOList?.filter { it.keyId == null }?.size != 1 &&
                                 BusinessManager.mDeviceTakeList.none { it.deviceType == DEVICE_TYPE_KEY && it.ticketId == ticketId }
+                    if (forceGetKey) isNeedKey = true
                     LogUtil.i("needLockCount = $needLockCount , readyLockCount = $readyLockCount, realCount = $realCount, isNeedKey = $isNeedKey")
                     BusinessManager.checkEquipCount(realCount, isNeedKey) { keyPair, lockMap ->
                         val lockCount = lockMap.flatMap { it.value }.count()

+ 2 - 2
app/src/main/java/com/grkj/iscs_mars/view/step_mode/StepMode2.kt

@@ -27,9 +27,9 @@ class StepMode2 : IStepMode {
                 true
             }
 
-            5 -> {
+            5, 6, 7 -> {
                 if (data.jobStatus == null) {
-                    false
+                    true
                 } else {
                     data.jobStatus < 4
                 }