Browse Source

refactor(硬件状态):
- 交叉作业流程修改

周文健 5 months ago
parent
commit
e1dabf529e

+ 2 - 1
app/build.gradle

@@ -1,6 +1,7 @@
 plugins {
 plugins {
     alias(libs.plugins.android.application)
     alias(libs.plugins.android.application)
     alias(libs.plugins.jetbrains.kotlin.android)
     alias(libs.plugins.jetbrains.kotlin.android)
+    id("org.jetbrains.kotlin.kapt")
     id("com.google.devtools.ksp")
     id("com.google.devtools.ksp")
 }
 }
 
 
@@ -87,7 +88,7 @@ dependencies {
     implementation(libs.viewmodel.ktx)
     implementation(libs.viewmodel.ktx)
     implementation(libs.viewmodel.livedata.ktx)
     implementation(libs.viewmodel.livedata.ktx)
     implementation(libs.viewmodel.savestate)
     implementation(libs.viewmodel.savestate)
-    ksp(libs.viewmodel.compiler)
+    kapt(libs.viewmodel.compiler)
 
 
     implementation(libs.room.runtime)
     implementation(libs.room.runtime)
     implementation(libs.room.ktx)
     implementation(libs.room.ktx)

+ 10 - 5
app/src/main/java/com/grkj/iscs/extentions/Context.kt

@@ -26,13 +26,14 @@ fun Context.removeNetObserver(observer: Observer<Boolean>) {
 }
 }
 
 
 @SuppressLint("MissingPermission")
 @SuppressLint("MissingPermission")
-fun Context.serialNo() : String {
+fun Context.serialNo(): String {
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
         && ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
         && ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
-        == PackageManager.PERMISSION_GRANTED) {
-        return Build.getSerial().toUpperCase(Locale.ROOT)
+        == PackageManager.PERMISSION_GRANTED
+    ) {
+        return Build.getSerial().uppercase(Locale.ROOT)
     }
     }
-    return Build.SERIAL.toUpperCase(Locale.ROOT)
+    return Build.SERIAL.uppercase(Locale.ROOT)
 }
 }
 
 
 /**
 /**
@@ -40,7 +41,11 @@ fun Context.serialNo() : String {
  */
  */
 fun Context.checkPermissions(permissions: Array<String>): Boolean {
 fun Context.checkPermissions(permissions: Array<String>): Boolean {
     for (permission in permissions) {
     for (permission in permissions) {
-        if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
+        if (ContextCompat.checkSelfPermission(
+                this,
+                permission
+            ) != PackageManager.PERMISSION_GRANTED
+        ) {
             return false
             return false
         }
         }
     }
     }

+ 31 - 7
app/src/main/java/com/grkj/iscs/view/fragment/JobProgressFragment.kt

@@ -12,8 +12,11 @@ import com.grkj.iscs.model.bo.PageChangeBO
 import com.grkj.iscs.model.eventmsg.MsgEvent
 import com.grkj.iscs.model.eventmsg.MsgEvent
 import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_UPDATE_TICKET_PROGRESS
 import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_UPDATE_TICKET_PROGRESS
 import com.grkj.iscs.model.eventmsg.UpdateTicketProgressMsg
 import com.grkj.iscs.model.eventmsg.UpdateTicketProgressMsg
+import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
 import com.grkj.iscs.model.vo.ticket.TicketDetailMonitorRespVO
 import com.grkj.iscs.model.vo.ticket.TicketDetailMonitorRespVO
 import com.grkj.iscs.model.vo.ticket.TicketDetailRespVO
 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.SPUtils
 import com.grkj.iscs.util.ToastUtils
 import com.grkj.iscs.util.ToastUtils
 import com.grkj.iscs.util.log.LogUtil
 import com.grkj.iscs.util.log.LogUtil
@@ -34,6 +37,7 @@ class JobProgressFragment(val goBack: () -> Unit) :
     private val mUserList = mutableListOf<TicketDetailMonitorRespVO.IsJobTicketUser>()
     private val mUserList = mutableListOf<TicketDetailMonitorRespVO.IsJobTicketUser>()
     private var mTicketDetail: TicketDetailRespVO? = null
     private var mTicketDetail: TicketDetailRespVO? = null
     private var mStep = 0
     private var mStep = 0
+    private var mCurrentStep: StepDetailRespVO? = null
     private var mPageChangeBO: PageChangeBO? = null
     private var mPageChangeBO: PageChangeBO? = null
     private var mTipDialog: TipDialog? = null
     private var mTipDialog: TipDialog? = null
     private lateinit var observer: Observer<MsgEvent>
     private lateinit var observer: Observer<MsgEvent>
@@ -121,21 +125,40 @@ class JobProgressFragment(val goBack: () -> Unit) :
             } else if (mStep == 7) {
             } else if (mStep == 7) {
                 val checkResult = presenter?.checkUnlock(requireContext(), mUserList)
                 val checkResult = presenter?.checkUnlock(requireContext(), mUserList)
                 if (checkResult?.isEmpty() == true) {
                 if (checkResult?.isEmpty() == true) {
-                    if (SPUtils.isKeyTake(mPageChangeBO?.ticketId!!)) {
+                    //如果所有隔离点都有交叉作业,弹窗提醒确认就结束
+                    if (mTicketDetail?.ticketPointsVOList?.all {
+                            it.pointId in (mTicketDetail?.noUnlockTicketPointsVOSet?.map { it.pointId }
+                                ?: mutableListOf())
+                        } == true) {
                         if (mTipDialog == null) {
                         if (mTipDialog == null) {
                             mTipDialog = TipDialog(requireContext())
                             mTipDialog = TipDialog(requireContext())
                         }
                         }
-                        mTipDialog?.setTip(getString(R.string.take_one_more_key_hint))
+                        mTipDialog?.setTip(getString(R.string.all_point_have_other_job_not_finish))
                         mTipDialog?.setType(TipDialog.TYPE_HINT)
                         mTipDialog?.setType(TipDialog.TYPE_HINT)
                         mTipDialog?.setConfirmListener {
                         mTipDialog?.setConfirmListener {
-                            BusinessManager.sendLoadingEventMsg(getString(R.string.system_is_processing))
-                            presenter?.handleUnlockProcess(mPageChangeBO?.ticketId!!)
+                            mCurrentStep?.stepId?.let {
+                                presenter?.updateStep(it, "1") {
+                                    goBack()
+                                }
+                            } ?: ToastUtils.tip(getString(R.string.current_step_can_not_be_process))
                         }
                         }
                         mTipDialog?.showCancelCountdown(10)
                         mTipDialog?.showCancelCountdown(10)
                     } else {
                     } else {
-                        BusinessManager.sendLoadingEventMsg(getString(R.string.system_is_processing))
-                        presenter?.handleUnlockProcess(mPageChangeBO?.ticketId!!)
-                        SPUtils.takeKey(mPageChangeBO?.ticketId!!)
+                        if (SPUtils.isKeyTake(mPageChangeBO?.ticketId!!)) {
+                            if (mTipDialog == null) {
+                                mTipDialog = TipDialog(requireContext())
+                            }
+                            mTipDialog?.setTip(getString(R.string.take_one_more_key_hint))
+                            mTipDialog?.setType(TipDialog.TYPE_HINT)
+                            mTipDialog?.setConfirmListener {
+                                BusinessManager.sendLoadingEventMsg(getString(R.string.system_is_processing))
+                                presenter?.handleUnlockProcess(mPageChangeBO?.ticketId!!)
+                            }
+                            mTipDialog?.showCancelCountdown(10)
+                        } else {
+                            BusinessManager.sendLoadingEventMsg(getString(R.string.system_is_processing))
+                            presenter?.handleUnlockProcess(mPageChangeBO?.ticketId!!)
+                        }
                     }
                     }
                 } else {
                 } else {
                     ToastUtils.tip(checkResult)
                     ToastUtils.tip(checkResult)
@@ -299,6 +322,7 @@ class JobProgressFragment(val goBack: () -> Unit) :
             it?.filter { it.stepStatus == "1" }?.maxByOrNull { it.stepIndex!! }?.stepIndex?.let {
             it?.filter { it.stepStatus == "1" }?.maxByOrNull { it.stepIndex!! }?.stepIndex?.let {
                 mStep = it
                 mStep = it
             }
             }
+            mCurrentStep = it?.get(mStep)
             handleActionBtnVisibility()
             handleActionBtnVisibility()
             callback?.invoke()
             callback?.invoke()
         }
         }

+ 8 - 0
app/src/main/java/com/grkj/iscs/view/presenter/JobProgressPresenter.kt

@@ -82,6 +82,14 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
         }
         }
     }
     }
 
 
+    fun updateStep(stepId: Long, stepStatus: String, callBack: (Boolean) -> Unit) {
+        NetApi.updateStep(stepId, stepStatus) {
+            Executor.runOnMain {
+                callBack.invoke(it)
+            }
+        }
+    }
+
     /**
     /**
      * 检查是否可以继续执行后续操作(例:点击后不拿设备或者无法拿设备,又再次点击按钮)
      * 检查是否可以继续执行后续操作(例:点击后不拿设备或者无法拿设备,又再次点击按钮)
      *
      *

+ 3 - 3
app/src/main/java/com/grkj/iscs/view/step_mode/StepMode2.kt

@@ -74,8 +74,8 @@ class StepMode2 : IStepMode {
         mPointList: MutableList<TicketDetailMonitorRespVO.IsJobTicketPointsVO>,
         mPointList: MutableList<TicketDetailMonitorRespVO.IsJobTicketPointsVO>,
         mUserList: MutableList<TicketDetailMonitorRespVO.IsJobTicketUser>
         mUserList: MutableList<TicketDetailMonitorRespVO.IsJobTicketUser>
     ): Boolean {
     ): Boolean {
-        //交叉作业要检查非不可解锁的区域外的所有区域的锁状态
-        return !mPointList.filter { it.pointId !in (mTicketDetail?.noUnlockTicketPointsVOSet?.map { it.pointId }?: mutableListOf()) }.all { it.pointStatus == "2" } && mUserList.all { it.jobStatus == 5 }
+        //交叉作业要检查所有共锁解除已完成
+        return mUserList.all { it.jobStatus == 5 }
     }
     }
 
 
     override fun colockerInsideCanAdd(user: UserListRespVO.Row, mStep: Int): Boolean {
     override fun colockerInsideCanAdd(user: UserListRespVO.Row, mStep: Int): Boolean {
@@ -147,7 +147,7 @@ class StepMode2 : IStepMode {
     }
     }
 
 
     override fun checkUnlock(mUserList: MutableList<TicketDetailMonitorRespVO.IsJobTicketUser>): String {
     override fun checkUnlock(mUserList: MutableList<TicketDetailMonitorRespVO.IsJobTicketUser>): String {
-        return if (mUserList.all { it.jobStatus!! >= 5 } == true) {
+        return if (mUserList.all { it.jobStatus!! >= 5 }) {
             ""
             ""
         } else {
         } else {
             ContextCompat.getString(
             ContextCompat.getString(

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

@@ -331,4 +331,5 @@
     <string name="take_one_more_key_hint">I have already taken out the key, would you like to take out another one</string>
     <string name="take_one_more_key_hint">I have already taken out the key, would you like to take out another one</string>
     <string name="current_user_does_not_have_the_authority_to_colock">The current user does not have the authority to colock</string>
     <string name="current_user_does_not_have_the_authority_to_colock">The current user does not have the authority to colock</string>
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">The current user does not have the authority to unlock colock</string>
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">The current user does not have the authority to unlock colock</string>
+    <string name="all_point_have_other_job_not_finish">all point have other job not finish,do you want to continue?</string>
 </resources>
 </resources>

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

@@ -331,4 +331,5 @@
     <string name="take_one_more_key_hint">已有钥匙取出,是否再取一个</string>
     <string name="take_one_more_key_hint">已有钥匙取出,是否再取一个</string>
     <string name="current_user_does_not_have_the_authority_to_colock">当前用户无权共锁</string>
     <string name="current_user_does_not_have_the_authority_to_colock">当前用户无权共锁</string>
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">当前用户无权解除共锁</string>
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">当前用户无权解除共锁</string>
+    <string name="all_point_have_other_job_not_finish">所有隔离点存在其他作业未完成,是否继续拆锁恢复?</string>
 </resources>
 </resources>

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

@@ -331,4 +331,5 @@
     <string name="take_one_more_key_hint">已有钥匙取出,是否再取一个</string>
     <string name="take_one_more_key_hint">已有钥匙取出,是否再取一个</string>
     <string name="current_user_does_not_have_the_authority_to_colock">当前用户无权共锁</string>
     <string name="current_user_does_not_have_the_authority_to_colock">当前用户无权共锁</string>
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">当前用户无权解除共锁</string>
     <string name="current_user_does_not_have_the_authority_to_unlock_colock">当前用户无权解除共锁</string>
+    <string name="all_point_have_other_job_not_finish">所有隔离点存在其他作业未完成,是否继续拆锁恢复?</string>
 </resources>
 </resources>

+ 1 - 1
build.gradle

@@ -2,5 +2,5 @@
 plugins {
 plugins {
     alias(libs.plugins.android.application) apply false
     alias(libs.plugins.android.application) apply false
     alias(libs.plugins.jetbrains.kotlin.android) apply false
     alias(libs.plugins.jetbrains.kotlin.android) apply false
-    id("com.google.devtools.ksp") version "1.9.0-1.0.13" apply false
+    id("com.google.devtools.ksp") version "2.1.10-1.0.31" apply false
 }
 }

+ 2 - 2
gradle/libs.versions.toml

@@ -1,6 +1,6 @@
 [versions]
 [versions]
 agp = "8.5.2"
 agp = "8.5.2"
-kotlin = "1.9.0"
+kotlin = "2.1.10"
 coreKtx = "1.13.0"
 coreKtx = "1.13.0"
 junit = "4.13.2"
 junit = "4.13.2"
 junitVersion = "1.1.5"
 junitVersion = "1.1.5"
@@ -39,7 +39,7 @@ viewmodel-savestate = { group = "androidx.lifecycle", name = "lifecycle-viewmode
 viewmodel-compiler = { group = "androidx.lifecycle", name = "lifecycle-compiler", version.ref = "lifecycle-version" }
 viewmodel-compiler = { group = "androidx.lifecycle", name = "lifecycle-compiler", version.ref = "lifecycle-version" }
 
 
 room-runtime = { group = "androidx.room",name = "room-runtime",version.ref = "room-version" }
 room-runtime = { group = "androidx.room",name = "room-runtime",version.ref = "room-version" }
-room-compiler = { group = "androidx.room",name = "room-ktx",version.ref = "room-version" }
+room-compiler = { group = "androidx.room",name = "room-compiler",version.ref = "room-version" }
 room-ktx = { group = "androidx.room",name = "room-ktx",version.ref = "room-version" }
 room-ktx = { group = "androidx.room",name = "room-ktx",version.ref = "room-version" }
 room-testing = { group = "androidx.room",name = "room-testing",version.ref = "room-version" }
 room-testing = { group = "androidx.room",name = "room-testing",version.ref = "room-version" }