Explorar o código

refactor(模式校验):
- 步骤模式校验 基本完成
- 人员模式校验 部分修改
- 进度模式校验 部分完成

周文健 hai 6 meses
pai
achega
fd9cb843bf

+ 2 - 2
app/src/main/java/com/grkj/iscs/model/Constants.kt

@@ -83,8 +83,8 @@ object Constants {
     val mSopTypeList = mutableListOf(SOP_REPAIR, SOP_PRE_MAINTENANCE, SOP_CHANGE_SHIFTS, SOP_CLEAN, SOP_SWITCH_PRODUCT)
 
     /*************************  虹软ArcSoft  *************************/
-    const val APP_ID = "6Hkb4JK1E1efeYbqY8T1jQVJqYWHcNcPRZKBf3oVtR5c"
-    const val SDK_KEY = "BpeNqNu9xtsKFKWv9EhYuufXkwQcvKSnTv7PK5B55A9Z"
+    const val APP_ID = "FTN3G4pk8n2RKwjD955sRapRjbYQFefwhHd4sBZMYEz6"
+    const val SDK_KEY = "BjJomNU2bQc2SYhT7NNqwvFd3WD4wTqecifNcDRuKD5G"
 
     /*************************  作业票类型  *************************/
     data class TicketType(val type: Int, val key: String)

+ 23 - 3
app/src/main/java/com/grkj/iscs/util/SPUtils.kt

@@ -30,6 +30,8 @@ object SPUtils {
     private const val KEY_DOCK_CONFIG = "dock_config"
     private const val KEY_PORT_CONFIG = "port_config"
 
+    private const val KEY_STEP_MODE = "step_mode"
+
     private const val KEY_DATA_UPDATE_LOCK_POINT = "update_lock_point"
     private const val KEY_DATA_UPDATE_KEY_RETURN = "update_key_return"
 
@@ -70,7 +72,7 @@ object SPUtils {
         edit.commit()
     }
 
-    fun clearLoginUser(context: Context) : Boolean {
+    fun clearLoginUser(context: Context): Boolean {
         return try {
             val sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE)
             val edit = sp.edit()
@@ -106,6 +108,18 @@ object SPUtils {
         return sp.getString(KEY_PORT_CONFIG, null)
     }
 
+    fun saveStepMode(context: Context, mode: Int) {
+        val sp = context.getSharedPreferences(SP_CONFIG_NAME, Context.MODE_PRIVATE)
+        val edit = sp.edit()
+        edit.putInt(KEY_STEP_MODE, mode)
+        edit.commit()
+    }
+
+    fun getStepMode(context: Context): Int {
+        val sp = context.getSharedPreferences(SP_CONFIG_NAME, Context.MODE_PRIVATE)
+        return sp.getInt(KEY_STEP_MODE, 0)
+    }
+
     fun saveUpdateLockPoint(context: Context, list: MutableList<LockPointUpdateReqVO>) {
         val sp = context.getSharedPreferences(SP_DATA, Context.MODE_PRIVATE)
         val edit = sp.edit()
@@ -157,7 +171,10 @@ object SPUtils {
         }
         try {
             val tempList: MutableList<UpdateKeyReturnBO> =
-                Gson().fromJson(listJson, object : TypeToken<MutableList<UpdateKeyReturnBO>>() {}.type)
+                Gson().fromJson(
+                    listJson,
+                    object : TypeToken<MutableList<UpdateKeyReturnBO>>() {}.type
+                )
             return tempList
         } catch (e: Exception) {
             LogUtil.e("${e.message}")
@@ -172,7 +189,10 @@ object SPUtils {
         edit.apply()
     }
 
-    fun saveSystemAttribute(context: Context, recordList: MutableList<SystemAttributePageRespVO.Record>) {
+    fun saveSystemAttribute(
+        context: Context,
+        recordList: MutableList<SystemAttributePageRespVO.Record>
+    ) {
         val sp = context.getSharedPreferences(SP_ATTRIBUTE, Context.MODE_PRIVATE)
         val edit = sp.edit()
         edit.putString(KEY_SYSTEM_ATTRIBUTE, Gson().toJson(recordList))

+ 45 - 12
app/src/main/java/com/grkj/iscs/view/fragment/JobProgressFragment.kt

@@ -42,26 +42,35 @@ class JobProgressFragment(val goBack: () -> Unit) :
 
     override fun initView() {
         mBinding?.cbBack?.setOnClickListener { goBack() }
-
         mBinding?.rvPoint?.adapter =
-            object : CommonAdapter<TicketDetailMonitorRespVO.IsJobTicketPointsVO>(requireActivity(), R.layout.item_rv_point, mPointList) {
-                override fun convert(holder: ViewHolder, point: TicketDetailMonitorRespVO.IsJobTicketPointsVO, position: Int) {
+            object : CommonAdapter<TicketDetailMonitorRespVO.IsJobTicketPointsVO>(
+                requireActivity(),
+                R.layout.item_rv_point,
+                mPointList
+            ) {
+                override fun convert(
+                    holder: ViewHolder,
+                    point: TicketDetailMonitorRespVO.IsJobTicketPointsVO,
+                    position: Int
+                ) {
                     holder.setText(R.id.tv_name, point.pointName)
                     holder.setText(R.id.tv_function, point.remark)
                     holder.setVisible(R.id.iv_status, point.switchStatus != null)
                     holder.getView<ImageView>(R.id.iv_status)
                         .setBackgroundResource(if (point.switchStatus == "1") R.mipmap.switch_off else R.mipmap.switch_on)
-                    when(point.pointStatus) {
+                    when (point.pointStatus) {
                         "1" -> {
                             holder.setVisible(R.id.ll_lock_status, true)
                             holder.getView<LinearLayout>(R.id.ll_lock_status).isSelected = false
                             holder.setText(R.id.tv_lock_status, getString(R.string.has_locked))
                         }
+
                         "2" -> {
                             holder.setVisible(R.id.ll_lock_status, true)
                             holder.getView<LinearLayout>(R.id.ll_lock_status).isSelected = true
                             holder.setText(R.id.tv_lock_status, getString(R.string.unlocked))
                         }
+
                         else -> {
                             holder.setVisible(R.id.ll_lock_status, false)
                         }
@@ -70,8 +79,16 @@ class JobProgressFragment(val goBack: () -> Unit) :
             }
 
         mBinding?.rvColocker?.adapter =
-            object : CommonAdapter<TicketDetailMonitorRespVO.IsJobTicketUser>(requireActivity(), R.layout.item_rv_worker_status, mUserList) {
-                override fun convert(holder: ViewHolder, user: TicketDetailMonitorRespVO.IsJobTicketUser, position: Int) {
+            object : CommonAdapter<TicketDetailMonitorRespVO.IsJobTicketUser>(
+                requireActivity(),
+                R.layout.item_rv_worker_status,
+                mUserList
+            ) {
+                override fun convert(
+                    holder: ViewHolder,
+                    user: TicketDetailMonitorRespVO.IsJobTicketUser,
+                    position: Int
+                ) {
                     holder.setText(R.id.tv_name, user.userName)
                     holder.setVisible(R.id.iv_ready_to_lock, mStep >= 6)
                     holder.setVisible(R.id.iv_locked, user.jobStatus!! >= 4)
@@ -115,7 +132,7 @@ class JobProgressFragment(val goBack: () -> Unit) :
     }
 
     override fun refreshPage(pageChangeBO: PageChangeBO) {
-        clearPage()
+//        clearPage()
         mPageChangeBO = pageChangeBO
 
         presenter?.getTicketDetail(pageChangeBO.ticketId) {
@@ -145,6 +162,9 @@ class JobProgressFragment(val goBack: () -> Unit) :
         mBinding?.tvLock?.text = "0/0/0"
     }
 
+    /**
+     * 共锁和解除共锁
+     */
     fun getCardNo(cardNo: String) {
         getStepDetail(mPageChangeBO?.ticketId!!) {
             presenter?.getCardInfoByNfc(cardNo) {
@@ -167,7 +187,11 @@ class JobProgressFragment(val goBack: () -> Unit) :
                         mTipDialog?.setTip(getString(R.string.confirm_to_uncolock, it.nickName))
                     }
                     mTipDialog?.setConfirmListener {
-                        presenter?.updateColockerStatus(mPageChangeBO?.ticketId!!, cardNo, if (jobStatus < 4) "4" else "5") {
+                        presenter?.updateColockerStatus(
+                            mPageChangeBO?.ticketId!!,
+                            cardNo,
+                            if (jobStatus < 4) "4" else "5"
+                        ) {
                             refreshPage(mPageChangeBO!!)
                         }
                     }
@@ -181,8 +205,10 @@ class JobProgressFragment(val goBack: () -> Unit) :
 
     private fun getStepDetail(ticketId: Long, callback: (() -> Unit)? = null) {
         presenter?.getStepDetail(ticketId) {
-            mBinding?.tvWorker?.text = "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
-            mBinding?.tvLock?.text = "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
+            mBinding?.tvWorker?.text =
+                "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
+            mBinding?.tvLock?.text =
+                "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
 
             it?.filter { it.stepStatus == "1" }?.maxByOrNull { it.stepIndex!! }?.stepIndex?.let {
                 mStep = it
@@ -196,14 +222,16 @@ class JobProgressFragment(val goBack: () -> Unit) :
         when (mStep) {
             4 -> {
                 mBinding?.cbAction?.setText(getString(R.string.go_locking))
+                mBinding?.cbAction?.setIcon(R.mipmap.ticket_lock)
                 if (mPointList.all { it.pointStatus == "1" }) {
                     mBinding?.cbAction?.visibility = View.GONE
                 } else {
                     mBinding?.cbAction?.visibility = View.VISIBLE
                 }
             }
+
             7 -> {
-                if (!mPointList.all { it.pointStatus == "2" }) {
+                if (presenter?.showGoToUnlock(requireContext(),mPointList,mUserList) == true) {
                     mBinding?.cbAction?.visibility = View.VISIBLE
                     mBinding?.cbAction?.setIcon(R.mipmap.ticket_unlocked)
                     mBinding?.cbAction?.setText(getString(R.string.go_unlocking))
@@ -211,6 +239,7 @@ class JobProgressFragment(val goBack: () -> Unit) :
                     mBinding?.cbAction?.visibility = View.GONE
                 }
             }
+
             else -> {
                 mBinding?.cbAction?.visibility = View.GONE
             }
@@ -235,10 +264,12 @@ class JobProgressFragment(val goBack: () -> Unit) :
                     }
                 }
             }
+
             6 -> {
                 mBinding?.llTip?.visibility = View.VISIBLE
                 mBinding?.tvTip?.text = getString(R.string.please_do_colock)
             }
+
             7 -> {
                 val keyCount = ticketDetail?.ticketKeyVOList?.count { it.keyId != null }
                 if (keyCount == 1) {
@@ -247,13 +278,15 @@ class JobProgressFragment(val goBack: () -> Unit) :
                 } else if (keyCount == 2) {
                     if (ticketDetail.ticketKeyVOList[1].keyStatus == "1") {
                         mBinding?.llTip?.visibility = View.VISIBLE
-                        mBinding?.tvTip?.text = getString(R.string.please_return_key_after_unlocking)
+                        mBinding?.tvTip?.text =
+                            getString(R.string.please_return_key_after_unlocking)
                     } else {
                         mBinding?.llTip?.visibility = View.GONE
                         mBinding?.tvTip?.text = ""
                     }
                 }
             }
+
             else -> {
                 mBinding?.llTip?.visibility = View.GONE
                 mBinding?.tvTip?.text = ""

+ 154 - 74
app/src/main/java/com/grkj/iscs/view/fragment/StepFragment.kt

@@ -12,6 +12,7 @@ import com.grkj.iscs.model.bo.PageChangeBO
 import com.grkj.iscs.model.vo.machinery.MachineryDetailRespVO
 import com.grkj.iscs.model.vo.ticket.LotoMapRespVO
 import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
+import com.grkj.iscs.model.vo.ticket.TicketDetailRespVO
 import com.grkj.iscs.util.BitmapUtil
 import com.grkj.iscs.util.SPUtils
 import com.grkj.iscs.util.ToastUtils
@@ -40,6 +41,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
     private var stationLayer: CustomStationLayer? = null
     private val mStationList = mutableListOf<CustomStationLayer.IsolationPoint>()
     private var mMapPicWidth = 1
+    private var mTicketDetailData: TicketDetailRespVO? = null
     private var mCanHandle: Boolean? = null // 是否可以操作,创建人、上锁人至少符合一个才可操作
 
     override val viewBinding: FragmentStepBinding
@@ -57,44 +59,48 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
             StepBO(R.mipmap.step7, getString(R.string.ensure_power_isolation), 6, "⑥"),
             StepBO(R.mipmap.step8, getString(R.string.lock_and_hang_a_sign), 5, "⑤")
         )
-        mBinding?.rvStep?.adapter = object : CommonAdapter<StepBO>(requireContext(), R.layout.item_rv_step, mStepList) {
-            override fun convert(holder: ViewHolder, step: StepBO, position: Int) {
-                if (step.stepDetail?.stepStatus == "1") {
-                    holder.getView<MaterialCardView>(R.id.cv_step)
-                        .setCardBackgroundColor(requireContext().getColor(R.color.item_rv_step_bg_done))
-                } else {
-                    holder.getView<MaterialCardView>(R.id.cv_step).setCardBackgroundColor(
-                        if (mStep + 1 == step.index)
-                            requireContext().getColor(R.color.item_rv_step_bg_doing)
-                        else
-                            requireContext().getColor(R.color.common_bg_white_10)
-                    )
-                }
-
-                holder.setVisible(R.id.iv_arrow_right, step.index !in 4..5)
-                holder.setVisible(R.id.iv_arrow_bottom, step.index == 4)
-                holder.getView<ImageView>(R.id.iv_arrow_right).rotation = if (step.index > 5) 180f else 0f
-                holder.getView<ImageView>(R.id.iv_icon).setImageResource(step.pic)
-                holder.setText(R.id.tv_name, step.stepDetail?.androidStepContent)
-                holder.setText(R.id.tv_index, step.indexStr)
-                holder.getView<ImageView>(R.id.iv_status).setImageResource(if (step.stepDetail?.stepStatus == "1") R.mipmap.step_executed else R.mipmap.step_not_executed)
-                holder.setText(R.id.tv_status,
+        mBinding?.rvStep?.adapter =
+            object : CommonAdapter<StepBO>(requireContext(), R.layout.item_rv_step, mStepList) {
+                override fun convert(holder: ViewHolder, step: StepBO, position: Int) {
                     if (step.stepDetail?.stepStatus == "1") {
-                        if (step.index == 3) getString(R.string.allocated) else getString(R.string.executed)
+                        holder.getView<MaterialCardView>(R.id.cv_step)
+                            .setCardBackgroundColor(requireContext().getColor(R.color.item_rv_step_bg_done))
                     } else {
-                        if (step.index == 3) getString(R.string.not_allocated) else getString(R.string.not_executed)
+                        holder.getView<MaterialCardView>(R.id.cv_step).setCardBackgroundColor(
+                            if (mStep + 1 == step.index)
+                                requireContext().getColor(R.color.item_rv_step_bg_doing)
+                            else
+                                requireContext().getColor(R.color.common_bg_white_10)
+                        )
                     }
-                )
-                holder.setOnClickListener(R.id.root) {
-                    mCanHandle ?: return@setOnClickListener
-                    if (mCanHandle == false) {
-                        ToastUtils.tip(R.string.no_permission_to_handle)
-                        return@setOnClickListener
+
+                    holder.setVisible(R.id.iv_arrow_right, step.index !in 4..5)
+                    holder.setVisible(R.id.iv_arrow_bottom, step.index == 4)
+                    holder.getView<ImageView>(R.id.iv_arrow_right).rotation =
+                        if (step.index > 5) 180f else 0f
+                    holder.getView<ImageView>(R.id.iv_icon).setImageResource(step.pic)
+                    holder.setText(R.id.tv_name, step.stepDetail?.androidStepContent)
+                    holder.setText(R.id.tv_index, step.indexStr)
+                    holder.getView<ImageView>(R.id.iv_status)
+                        .setImageResource(if (step.stepDetail?.stepStatus == "1") R.mipmap.step_executed else R.mipmap.step_not_executed)
+                    holder.setText(
+                        R.id.tv_status,
+                        if (step.stepDetail?.stepStatus == "1") {
+                            if (step.index == 3) getString(R.string.allocated) else getString(R.string.executed)
+                        } else {
+                            if (step.index == 3) getString(R.string.not_allocated) else getString(R.string.not_executed)
+                        }
+                    )
+                    holder.setOnClickListener(R.id.root) {
+                        mCanHandle ?: return@setOnClickListener
+                        if (mCanHandle == false) {
+                            ToastUtils.tip(R.string.no_permission_to_handle)
+                            return@setOnClickListener
+                        }
+                        handleStep(step.index)
                     }
-                    handleStep(step.index)
                 }
             }
-        }
 
         mBinding?.cbBack?.setOnClickListener { goBack() }
 
@@ -132,8 +138,12 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
                 return@setOnClickListener
             }
             if (mStep >= 4) {
-                changePage(PageChangeBO(2, mChangePage?.workstationId, mChangePage?.ticketId,
-                    mChangePage?.machineryId, mChangePage?.machineryName))
+                changePage(
+                    PageChangeBO(
+                        2, mChangePage?.workstationId, mChangePage?.ticketId,
+                        mChangePage?.machineryId, mChangePage?.machineryName
+                    )
+                )
             }
         }
 
@@ -149,7 +159,8 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
                     return
                 }
                 stationLayer = CustomStationLayer(mBinding?.mapview, mStationList)
-                stationLayer?.setMarkIsClickListener(object : CustomStationLayer.MarkIsClickListener {
+                stationLayer?.setMarkIsClickListener(object :
+                    CustomStationLayer.MarkIsClickListener {
                     override fun markIsClick(index: Int, btnIndex: Int) {
 //                        ToastUtils.tip(mPointList[index].name + " is selected, btnIndex is " + btnIndex)
                     }
@@ -170,6 +181,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
         mCanHandle = null
 
         presenter?.getTicketDetail(pageChangeBO.ticketId) {
+            mTicketDetailData = it
             mBinding?.tvTitle?.text = it?.ticketName
             it?.createBy?.let { itCreator ->
                 if (itCreator.isEmpty()) {
@@ -177,13 +189,17 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
                 }
                 mCanHandle = itCreator.toLong() == SPUtils.getLoginUser(requireContext())?.userId
             }
-            mCanHandle = (mCanHandle == true) || it?.ticketUserVOList?.any { it.userId != null && it.userId.toLong() == SPUtils.getLoginUser(requireContext())?.userId } == true
+            mCanHandle = (mCanHandle == true) || it?.ticketUserVOList?.any {
+                it.userId != null && it.userId.toLong() == SPUtils.getLoginUser(requireContext())?.userId
+            } == true
         }
 
         presenter?.getStepDetail(pageChangeBO.ticketId!!) {
             BusinessManager.sendLoadingEventMsg(null, false)
-            mBinding?.tvWorker?.text = "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
-            mBinding?.tvLock?.text = "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
+            mBinding?.tvWorker?.text =
+                "${it?.get(2)?.userNum}/${it?.get(4)?.userNum}/${it?.get(7)?.userNum}"
+            mBinding?.tvLock?.text =
+                "${it?.get(2)?.lockNum}/${it?.get(4)?.lockNum}/${it?.get(7)?.lockNum}"
             mStepList.forEach { step ->
                 step.stepDetail = it?.find { it.stepIndex == step.index }
             }
@@ -203,7 +219,8 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
             handleBottomTip()
         }
 
-        presenter?.getMachineryDetail(pageChangeBO.machineryId!!,
+        presenter?.getMachineryDetail(
+            pageChangeBO.machineryId!!,
             {
                 mMachineryDetail = it
                 Glide.with(this).load(it?.machineryImg).into(mBinding?.ivMachinery!!)
@@ -227,16 +244,26 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
                             val location = IntArray(2)
                             mBinding?.mapview?.getLocationOnScreen(location)
                             itMapInfo.pointList?.forEach { itPoint ->
-                                val locationX = (itPoint.x!!.toFloat() - (itMapInfo.x!!.toFloat() / 50))  * 50 / itMapInfo.width!!.toFloat() * it.width
-                                val locationY = (itPoint.y!!.toFloat() + 1 - itMapInfo.y!!.toFloat() / 50) * 50 / itMapInfo.height!!.toFloat() * it.height
+                                val locationX =
+                                    (itPoint.x!!.toFloat() - (itMapInfo.x!!.toFloat() / 50)) * 50 / itMapInfo.width!!.toFloat() * it.width
+                                val locationY =
+                                    (itPoint.y!!.toFloat() + 1 - itMapInfo.y!!.toFloat() / 50) * 50 / itMapInfo.height!!.toFloat() * it.height
                                 BitmapUtil.loadBitmapFromUrl(
-                                    requireContext(), itPoint.pointIcon!!, reqWidth = 18, reqHeight = 18
+                                    requireContext(),
+                                    itPoint.pointIcon!!,
+                                    reqWidth = 18,
+                                    reqHeight = 18
                                 ) { itBitmap ->
                                     mStationList.add(
                                         CustomStationLayer.IsolationPoint(
                                             PointF(locationX, locationY),
                                             itPoint.entityName!!,
-                                            itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(requireContext(), R.mipmap.ticket_type_placeholder, 18, 18),
+                                            itBitmap ?: BitmapUtil.getResizedBitmapFromMipmap(
+                                                requireContext(),
+                                                R.mipmap.ticket_type_placeholder,
+                                                18,
+                                                18
+                                            ),
                                             itPoint.entityId!!,
                                             mMachineryDetail?.pointIdList?.contains(itPoint.entityId) == true
                                         )
@@ -257,12 +284,21 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
         if (mStep == 0) return
         when (step) {
             3 -> {
-                if (mStep > 5) {
+                if (presenter?.canModifyColocker(requireContext(), step) == true) {
                     ToastUtils.tip(R.string.current_step_can_not_be_process)
                     return
                 }
-                changePage(PageChangeBO(1, mChangePage?.workstationId, mChangePage?.ticketId, mChangePage?.machineryId, mChangePage?.machineryName))
+                changePage(
+                    PageChangeBO(
+                        1,
+                        mChangePage?.workstationId,
+                        mChangePage?.ticketId,
+                        mChangePage?.machineryId,
+                        mChangePage?.machineryName
+                    )
+                )
             }
+
             4 -> {
                 if (mStep != 3) {
                     ToastUtils.tip(R.string.current_step_can_not_be_process)
@@ -270,6 +306,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
                 }
                 updateStep(4)
             }
+
             5, 6, 7, 8 -> {
                 if (mStep != step - 1) {
                     ToastUtils.tip(R.string.current_step_can_not_be_process)
@@ -281,37 +318,66 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
     }
 
     private fun updateStep(step: Int) {
-        val str = when (step) {
-            4 -> getString(R.string.action_confirm_shut_down)
-            5 -> getString(R.string.action_confirm_lock)
-            6 -> getString(R.string.action_confirm_power_isolation)
-            7 -> getString(R.string.action_confirm_check_before_unlocking)
-            8 -> getString(R.string.action_confirm_restore)
-            else -> ""
-        }
-        mTipDialog.setTip(str)
-        mTipDialog.setConfirmListener {
-            BusinessManager.sendLoadingEventMsg(getString(R.string.is_processing_please_wait))
-            if (step == 4) {
-                presenter?.updateStep(mStepList[2].stepDetail?.stepId!!, "1") {
-                    presenter?.updateStep(mStepList[3].stepDetail?.stepId!!, "1") {
-                        BusinessManager.sendLoadingEventMsg(null, false)
-                        refreshPage(mChangePage!!)
-                        // 自动跳转
-                        changePage(PageChangeBO(2, mChangePage?.workstationId, mChangePage?.ticketId,
-                            mChangePage?.machineryId, mChangePage?.machineryName))
+        if (presenter?.checkCanContinue(requireContext(), step, mTicketDetailData)
+                ?.isEmpty() == true
+        ) {
+            val str = when (step) {
+                4 -> getString(R.string.action_confirm_shut_down)
+                5 -> getString(R.string.action_confirm_lock)
+                6 -> getString(R.string.action_confirm_power_isolation)
+                7 -> getString(R.string.action_confirm_check_before_unlocking)
+                8 -> getString(R.string.action_confirm_restore)
+                else -> ""
+            }
+            mTipDialog.setTip(str)
+            mTipDialog.setConfirmListener {
+                BusinessManager.sendLoadingEventMsg(getString(R.string.is_processing_please_wait))
+                when (step) {
+                    4 -> {
+                        presenter?.updateStep(mStepList[2].stepDetail?.stepId!!, "1") {
+                            presenter?.updateStep(mStepList[3].stepDetail?.stepId!!, "1") {
+                                BusinessManager.sendLoadingEventMsg(null, false)
+                                refreshPage(mChangePage!!)
+                                // 自动跳转
+                                changePage(
+                                    PageChangeBO(
+                                        2, mChangePage?.workstationId, mChangePage?.ticketId,
+                                        mChangePage?.machineryId, mChangePage?.machineryName
+                                    )
+                                )
+                            }
+                        }
                     }
-                }
-            } else {
-                presenter?.updateStep(mStepList.find { it.index == step }?.stepDetail?.stepId!!, "1") {
-                    refreshPage(mChangePage!!)
-                    if (step == 6 || step == 7) {
-                        // 自动跳转
-                        changePage(PageChangeBO(2, mChangePage?.workstationId, mChangePage?.ticketId,
-                            mChangePage?.machineryId, mChangePage?.machineryName))
+
+                    else -> {
+                        presenter?.updateStep(
+                            mStepList.find { it.index == step }?.stepDetail?.stepId!!,
+                            "1"
+                        ) {
+                            refreshPage(mChangePage!!)
+                            if (step == 6 || step == 7) {
+                                // 自动跳转
+                                changePage(
+                                    PageChangeBO(
+                                        2, mChangePage?.workstationId, mChangePage?.ticketId,
+                                        mChangePage?.machineryId, mChangePage?.machineryName
+                                    )
+                                )
+                            }
+                        }
                     }
                 }
             }
+        } else {
+            val str = when (step) {
+                4 -> getString(R.string.action_confirm_shut_down)
+                5 -> getString(R.string.action_confirm_lock)
+                6 -> getString(R.string.action_confirm_power_isolation)
+                7 -> getString(R.string.action_confirm_check_before_unlocking)
+                8 -> getString(R.string.action_confirm_restore)
+                else -> ""
+            }
+            mTipDialog.setTip(str)
         }
         mTipDialog.show()
     }
@@ -322,24 +388,32 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
             2 -> {
                 mBinding?.tvTip?.text = getString(R.string.waiting_for_allocating_worker)
             }
+
             3 -> {
                 mBinding?.tvTip?.text = getString(R.string.waiting_for_shutting_down)
             }
+
             4 -> {
                 mBinding?.tvTip?.text = getString(R.string.waiting_for_hanging_a_sign)
             }
+
             5 -> {
                 mBinding?.tvTip?.text = getString(R.string.waiting_for_power_isolation)
             }
+
             6 -> {
                 mBinding?.tvTip?.text = getString(R.string.waiting_for_checking_before_unlocking)
             }
+
             7 -> {
-                mBinding?.tvTip?.text = getString(R.string.waiting_for_restoring_switch_before_unlocking)
+                mBinding?.tvTip?.text =
+                    getString(R.string.waiting_for_restoring_switch_before_unlocking)
             }
+
             8 -> {
                 mBinding?.tvTip?.text = getString(R.string.waiting_for_finishing)
             }
+
             else -> {
                 mBinding?.tvTip?.text = ""
             }
@@ -355,5 +429,11 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
         return StepPresenter()
     }
 
-    data class StepBO(val pic: Int, val title: String, val index: Int, val indexStr: String, var stepDetail: StepDetailRespVO? = null)
+    data class StepBO(
+        val pic: Int,
+        val title: String,
+        val index: Int,
+        val indexStr: String,
+        var stepDetail: StepDetailRespVO? = null
+    )
 }

+ 8 - 6
app/src/main/java/com/grkj/iscs/view/fragment/WorkerFragment.kt

@@ -62,12 +62,14 @@ class WorkerFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> U
                     holder.getView<ImageView>(R.id.iv_photo).isSelected = true
                     holder.setText(R.id.tv_name, data.userName)
                     holder.setOnClickListener(R.id.root) {
-                        // 共锁人取消
-                        mSelectedList.removeIf { it.userId == data.userId }
-                        mColockerSelectedShowList.removeIf { it.userId == data.userId }
-                        mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
-                        mBinding?.rvColockerInside?.adapter?.notifyDataSetChanged()
-                        mBinding?.rvColockerOutside?.adapter?.notifyDataSetChanged()
+                        if (presenter?.colockerCanRemove(requireContext(), data, mStep) == true) {
+                            // 共锁人取消
+                            mSelectedList.removeIf { it.userId == data.userId }
+                            mColockerSelectedShowList.removeIf { it.userId == data.userId }
+                            mBinding?.rvColockerSelected?.adapter?.notifyDataSetChanged()
+                            mBinding?.rvColockerInside?.adapter?.notifyDataSetChanged()
+                            mBinding?.rvColockerOutside?.adapter?.notifyDataSetChanged()
+                        }
                     }
                 }
             }

+ 26 - 3
app/src/main/java/com/grkj/iscs/view/presenter/JobProgressPresenter.kt

@@ -1,5 +1,6 @@
 package com.grkj.iscs.view.presenter
 
+import android.content.Context
 import com.grkj.iscs.BusinessManager
 import com.grkj.iscs.R
 import com.grkj.iscs.extentions.serialNo
@@ -13,9 +14,7 @@ import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_KEY
 import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_LOCK
 import com.grkj.iscs.model.eventmsg.DeviceExceptionMsg
 import com.grkj.iscs.model.eventmsg.MsgEvent
-import com.grkj.iscs.model.eventmsg.MsgEventConstants
 import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_DEVICE_EXCEPTION
-import com.grkj.iscs.model.eventmsg.UpdateTicketProgressMsg
 import com.grkj.iscs.model.vo.card.CardInfoRespVO
 import com.grkj.iscs.model.vo.lock.LockTakeUpdateReqVO
 import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
@@ -164,7 +163,7 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
                                 ToastUtils.tip(R.string.all_point_already_locked)
                                 keyPair.second?.rfid?.let { keyNfc ->
                                     BusinessManager.handleVirtualKeyGive(ticketId, keyNfc) {
-                                        BusinessManager.handleVirtualKeyReturn(ticketId, keyNfc){
+                                        BusinessManager.handleVirtualKeyReturn(ticketId, keyNfc) {
                                             BusinessManager.sendLoadingEventMsg(null, false)
                                         }
                                     }
@@ -314,4 +313,28 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
             tipDialog?.show()
         }
     }
+
+    /**
+     * 是否显示去解锁
+     */
+    fun showGoToUnlock(
+        context: Context,
+        mPointList: MutableList<TicketDetailMonitorRespVO.IsJobTicketPointsVO>,
+        mUserList: MutableList<TicketDetailMonitorRespVO.IsJobTicketUser>
+    ): Boolean {
+        val stepMode = SPUtils.getStepMode(context)
+        return when (stepMode) {
+            0 -> {
+                !mPointList.all { it.pointStatus == "2" }
+            }
+
+            1 -> {
+                !mPointList.all { it.pointStatus == "2" } && mUserList.all { it.jobStatus == 5 }
+            }
+
+            else -> {
+                false
+            }
+        }
+    }
 }

+ 70 - 1
app/src/main/java/com/grkj/iscs/view/presenter/StepPresenter.kt

@@ -1,5 +1,6 @@
 package com.grkj.iscs.view.presenter
 
+import android.content.Context
 import com.grkj.iscs.R
 import com.grkj.iscs.model.vo.machinery.MachineryDetailRespVO
 import com.grkj.iscs.model.vo.map.MapInfoRespVO
@@ -8,6 +9,7 @@ import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
 import com.grkj.iscs.model.vo.ticket.TicketDetailRespVO
 import com.grkj.iscs.util.Executor
 import com.grkj.iscs.util.NetApi
+import com.grkj.iscs.util.SPUtils
 import com.grkj.iscs.util.ToastUtils
 import com.grkj.iscs.view.base.BasePresenter
 import com.grkj.iscs.view.iview.IStepView
@@ -22,7 +24,11 @@ class StepPresenter : BasePresenter<IStepView>() {
         }
     }
 
-    fun getMachineryDetail(machineryId: Long, callBack: (MachineryDetailRespVO?) -> Unit, mapCallBack: (MutableList<LotoMapRespVO>?) -> Unit) {
+    fun getMachineryDetail(
+        machineryId: Long,
+        callBack: (MachineryDetailRespVO?) -> Unit,
+        mapCallBack: (MutableList<LotoMapRespVO>?) -> Unit
+    ) {
         NetApi.getMachineryDetail(machineryId) {
             NetApi.getLotoMapData(it?.lotoId!!) {
                 Executor.runOnMain {
@@ -81,4 +87,67 @@ class StepPresenter : BasePresenter<IStepView>() {
             }
         }
     }
+
+    /**
+     * 是否可以修改共锁人
+     */
+    fun canModifyColocker(context: Context, step: Int): Boolean {
+        val stepMode = SPUtils.getStepMode(context)
+        return when (stepMode) {
+            0 -> {
+                step > 5
+            }
+
+            1 -> {
+                step in 3..7
+            }
+
+            else -> {
+                false
+            }
+        }
+    }
+
+    /**
+     * 检查是否可以继续
+     */
+    fun checkCanContinue(
+        context: Context,
+        step: Int,
+        mTicketDetailData: TicketDetailRespVO?
+    ): String {
+        val stepMode = SPUtils.getStepMode(context)
+        return when (stepMode) {
+            0 -> {
+                when (step) {
+                    else -> ""
+                }
+            }
+
+            1 -> {
+                when (step) {
+                    6 -> {
+                        if (mTicketDetailData?.ticketUserVOList?.all { it.jobStatus!! >= 4 } == true) {
+                            ""
+                        } else {
+                            context.getString(R.string.please_wait_all_colocker_locked)
+                        }
+                    }
+
+                    8 -> {
+                        if (mTicketDetailData?.ticketUserVOList?.all { it.jobStatus!! == 5 } == true && mTicketDetailData.ticketPointsVOList?.all { it.pointStatus == "2" } == true) {
+                            ""
+                        } else {
+                            context.getString(R.string.please_wait_all_colocker_and_points_unlocked)
+                        }
+                    }
+                    else -> ""
+                }
+            }
+
+            else -> {
+                ""
+            }
+        }
+    }
 }

+ 26 - 0
app/src/main/java/com/grkj/iscs/view/presenter/WorkerPresenter.kt

@@ -1,5 +1,6 @@
 package com.grkj.iscs.view.presenter
 
+import android.content.Context
 import com.grkj.iscs.R
 import com.grkj.iscs.model.Constants.USER_ROLE_LOCKER
 import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
@@ -8,6 +9,7 @@ import com.grkj.iscs.model.vo.ticket.TicketUserReqVO
 import com.grkj.iscs.model.vo.user.UserListRespVO
 import com.grkj.iscs.util.Executor
 import com.grkj.iscs.util.NetApi
+import com.grkj.iscs.util.SPUtils
 import com.grkj.iscs.util.ToastUtils
 import com.grkj.iscs.view.base.BasePresenter
 import com.grkj.iscs.view.iview.IWorkerView
@@ -68,4 +70,28 @@ class WorkerPresenter : BasePresenter<IWorkerView>() {
             }
         }
     }
+
+    /**
+     * 是否可以移除共锁人
+     */
+    fun colockerCanRemove(context: Context, data: TicketUserReqVO, step: Int): Boolean {
+        val stepMode = SPUtils.getStepMode(context)
+        return when (stepMode) {
+            0 -> {
+                true
+            }
+
+            1 -> {
+                when (step) {
+                    3, 4 -> {
+                        true
+                    }
+
+                    else -> false
+                }
+            }
+
+            else -> false
+        }
+    }
 }

+ 2 - 0
app/src/main/res/values-en/strings.xml

@@ -314,4 +314,6 @@
     <string name="ticket_processing">operation in progress</string>
     <string name="has_no_point_can_unlock">has no point can unlock</string>
     <string name="all_point_already_locked">all point already locked</string>
+    <string name="please_wait_all_colocker_locked">please wait all colocker locked</string>
+    <string name="please_wait_all_colocker_and_points_unlocked">please wait all colocker and points unlocked</string>
 </resources>

+ 2 - 0
app/src/main/res/values-zh/strings.xml

@@ -314,4 +314,6 @@
     <string name="ticket_processing">进行中的作业</string>
     <string name="has_no_point_can_unlock">暂无隔离点可以解锁</string>
     <string name="all_point_already_locked">所有隔离点已上锁</string>
+    <string name="please_wait_all_colocker_locked">请等待所有共锁人上锁</string>
+    <string name="please_wait_all_colocker_and_points_unlocked">请等待所有共锁人和隔离点解锁</string>
 </resources>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -314,4 +314,6 @@
     <string name="ticket_processing">进行中的作业</string>
     <string name="has_no_point_can_unlock">暂无隔离点可以解锁</string>
     <string name="all_point_already_locked">所有隔离点已上锁</string>
+    <string name="please_wait_all_colocker_locked">请等待所有共锁人上锁</string>
+    <string name="please_wait_all_colocker_and_points_unlocked">请等待所有共锁人和隔离点解锁</string>
 </resources>