|
|
@@ -19,7 +19,6 @@ import com.grkj.iscs.model.vo.lock.LockTakeUpdateReqVO
|
|
|
import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
|
|
|
import com.grkj.iscs.model.vo.ticket.TicketDetailMonitorRespVO
|
|
|
import com.grkj.iscs.model.vo.ticket.TicketDetailRespVO
|
|
|
-import com.grkj.iscs.model.vo.ticket.TicketEquipDetailRespVO
|
|
|
import com.grkj.iscs.util.Executor
|
|
|
import com.grkj.iscs.util.NetApi
|
|
|
import com.grkj.iscs.util.SPUtils
|
|
|
@@ -32,21 +31,6 @@ import com.grkj.iscs.view.iview.IJobProgressView
|
|
|
class JobProgressPresenter : BasePresenter<IJobProgressView>() {
|
|
|
private var tipDialog: TipDialog? = null
|
|
|
|
|
|
- /**
|
|
|
- * 获取作业票详细信息
|
|
|
- */
|
|
|
- fun getTicketDetail(ticketId: Long?, callBack: (TicketDetailRespVO?) -> Unit) {
|
|
|
- if (ticketId == null) {
|
|
|
- ToastUtils.tip(mContext!!.resources.getString(R.string.ticket_id_is_null))
|
|
|
- return
|
|
|
- }
|
|
|
- NetApi.getTicketDetail(ticketId) {
|
|
|
- Executor.runOnMain {
|
|
|
- callBack.invoke(it)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
fun getStepDetail(ticketId: Long, callBack: (MutableList<StepDetailRespVO>?) -> Unit) {
|
|
|
NetApi.getStepDetail(ticketId) {
|
|
|
Executor.runOnMain {
|
|
|
@@ -79,8 +63,12 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fun getEquipDetail(ticketId: Long, callBack: (TicketEquipDetailRespVO?) -> Unit) {
|
|
|
- NetApi.getTicketEquipDetail(ticketId) {
|
|
|
+ fun getTicketDetail(ticketId: Long?, callBack: (TicketDetailRespVO?) -> Unit) {
|
|
|
+ if (ticketId == null) {
|
|
|
+ ToastUtils.tip(mContext!!.resources.getString(R.string.ticket_id_is_null))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ NetApi.getTicketDetail(ticketId) {
|
|
|
Executor.runOnMain {
|
|
|
callBack(it)
|
|
|
}
|
|
|
@@ -101,27 +89,32 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
|
|
|
* 上锁人上锁流程
|
|
|
*/
|
|
|
fun handleLockProcess(ticketId: Long) {
|
|
|
- getTicketDetail(ticketId) { ticketDetail ->
|
|
|
- LogUtil.i("getTicketDetail lock: $ticketDetail")
|
|
|
- val role = ticketDetail?.jobTicketUserList?.find { it.userId == SPUtils.getLoginUser(mContext!!)?.userId && it.userType == USER_TYPE_LOCKER }
|
|
|
- if (role == null) {
|
|
|
- ToastUtils.tip(R.string.you_are_not_locker_tip)
|
|
|
+ NetApi.checkBeforeAction(ticketId, true) {
|
|
|
+ if (!it) {
|
|
|
+ LogUtil.w("handleLockProcess check false")
|
|
|
BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
- return@getTicketDetail
|
|
|
+ return@checkBeforeAction
|
|
|
}
|
|
|
+ getTicketDetail(ticketId) { ticketDetail ->
|
|
|
+ LogUtil.i("getTicketDetail lock: $ticketDetail")
|
|
|
+ val role = ticketDetail?.ticketUserVOList?.find { it.userId == SPUtils.getLoginUser(mContext!!)?.userId && it.userType == USER_TYPE_LOCKER }
|
|
|
+ if (role == null) {
|
|
|
+ ToastUtils.tip(R.string.you_are_not_locker_tip)
|
|
|
+ BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
+ return@getTicketDetail
|
|
|
+ }
|
|
|
|
|
|
- // 3个状态全检查锁和钥匙分配情况,防止第一次拿了钥匙和部分锁
|
|
|
- if (role.jobStatus == JOB_STATUS_NOT_STARTED || role.jobStatus == JOB_STATUS_ACQUIRE_LOCK || role.jobStatus == JOB_STATUS_ACQUIRE_KEY) {
|
|
|
- NetApi.getTicketEquipDetail(ticketId) { equipDetail ->
|
|
|
- LogUtil.i("EquipDetail : $equipDetail")
|
|
|
+ // 3个状态全检查锁和钥匙分配情况,防止第一次拿了钥匙和部分锁
|
|
|
+ if (role.jobStatus == JOB_STATUS_NOT_STARTED || role.jobStatus == JOB_STATUS_ACQUIRE_LOCK || role.jobStatus == JOB_STATUS_ACQUIRE_KEY) {
|
|
|
+ LogUtil.i("EquipDetail : $ticketDetail")
|
|
|
// 取锁具、取钥匙
|
|
|
- val needLockCount = equipDetail?.ticketLockVOList?.count { it.lockId == null } ?: 0
|
|
|
+ val needLockCount = ticketDetail.ticketLockVOList?.count { it.lockId == null } ?: 0
|
|
|
val readyLockCount = BusinessManager.mDeviceTakeList.count { it.deviceType == DEVICE_TYPE_LOCK && it.ticketId == ticketId }
|
|
|
val realCount = (needLockCount - readyLockCount).coerceAtLeast(0)
|
|
|
if (readyLockCount > 0) {
|
|
|
ToastUtils.tip(R.string.please_take_out_ready_device_first)
|
|
|
}
|
|
|
- val isNeedKey = equipDetail?.ticketKeyVOList?.filter { it.keyId == null }?.size != 1
|
|
|
+ val isNeedKey = ticketDetail.ticketKeyVOList?.filter { it.keyId == null }?.size != 1
|
|
|
&& BusinessManager.mDeviceTakeList.none { it.deviceType == DEVICE_TYPE_KEY && it.ticketId == ticketId }
|
|
|
LogUtil.i("needLockCount = $needLockCount , readyLockCount = $readyLockCount, realCount = $realCount, isNeedKey = $isNeedKey")
|
|
|
BusinessManager.checkEquipCount(realCount, isNeedKey) { keyPair, lockMap ->
|
|
|
@@ -149,11 +142,11 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
|
|
|
handleGiveKey(ticketDetail, keyPair, lockMap)
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ LogUtil.w("Can't lock in current step")
|
|
|
+ ToastUtils.tip(R.string.can_not_lock_in_current_step)
|
|
|
+ BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
}
|
|
|
- } else {
|
|
|
- LogUtil.w("Can't lock in current step")
|
|
|
- ToastUtils.tip(R.string.can_not_lock_in_current_step)
|
|
|
- BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -185,31 +178,38 @@ class JobProgressPresenter : BasePresenter<IJobProgressView>() {
|
|
|
* 上锁人解锁流程
|
|
|
*/
|
|
|
fun handleUnlockProcess(ticketId: Long, keyRfid: String? = null) {
|
|
|
- getTicketDetail(ticketId) { ticketDetail ->
|
|
|
- LogUtil.i("getTicketDetail unlock: $ticketDetail")
|
|
|
- val role = ticketDetail?.jobTicketUserList?.find { it.userId == SPUtils.getLoginUser(mContext!!)?.userId && it.userType == USER_TYPE_LOCKER }
|
|
|
- if (role == null) {
|
|
|
- ToastUtils.tip(R.string.you_are_not_locker_tip)
|
|
|
+ NetApi.checkBeforeAction(ticketId, false) {
|
|
|
+ if (!it) {
|
|
|
+ LogUtil.w("handleUnlockProcess check false")
|
|
|
BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
- return@getTicketDetail
|
|
|
+ return@checkBeforeAction
|
|
|
}
|
|
|
- BusinessManager.checkEquipCount(0, true) { keyPair, _ ->
|
|
|
- // null表示锁具数量不够,不给钥匙
|
|
|
- if (keyPair == null) {
|
|
|
+ getTicketDetail(ticketId) { ticketDetail ->
|
|
|
+ LogUtil.i("getTicketDetail unlock: $ticketDetail")
|
|
|
+ val role = ticketDetail?.ticketUserVOList?.find { it.userId == SPUtils.getLoginUser(mContext!!)?.userId && it.userType == USER_TYPE_LOCKER }
|
|
|
+ if (role == null) {
|
|
|
+ ToastUtils.tip(R.string.you_are_not_locker_tip)
|
|
|
BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
- keyRfid?.let {
|
|
|
- showKeyErrorDialog(it)
|
|
|
- }
|
|
|
- } else {
|
|
|
- BusinessManager.addDeviceTake(DEVICE_TYPE_KEY, ticketId, keyPair.second?.rfid!!)
|
|
|
+ return@getTicketDetail
|
|
|
+ }
|
|
|
+ BusinessManager.checkEquipCount(0, true) { keyPair, _ ->
|
|
|
+ // null表示锁具数量不够,不给钥匙
|
|
|
+ if (keyPair == null) {
|
|
|
+ BusinessManager.sendLoadingEventMsg(null, false)
|
|
|
+ keyRfid?.let {
|
|
|
+ showKeyErrorDialog(it)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ BusinessManager.addDeviceTake(DEVICE_TYPE_KEY, ticketId, keyPair.second?.rfid!!)
|
|
|
|
|
|
- BusinessManager.getCurrentStatus(5, BusinessManager.getBleDeviceByMac(keyPair.second?.mac)!!.bleDevice) {
|
|
|
- if (!it) {
|
|
|
- return@getCurrentStatus
|
|
|
+ BusinessManager.getCurrentStatus(5, BusinessManager.getBleDeviceByMac(keyPair.second?.mac)!!.bleDevice) {
|
|
|
+ if (!it) {
|
|
|
+ return@getCurrentStatus
|
|
|
+ }
|
|
|
+ LogUtil.w("handleUnlockProcess timeout")
|
|
|
+ BusinessManager.removeDeviceTake(DEVICE_TYPE_KEY, keyPair.second?.rfid!!)
|
|
|
+ handleUnlockProcess(ticketId, keyPair.second?.rfid!!)
|
|
|
}
|
|
|
- LogUtil.w("handleUnlockProcess timeout")
|
|
|
- BusinessManager.removeDeviceTake(DEVICE_TYPE_KEY, keyPair.second?.rfid!!)
|
|
|
- handleUnlockProcess(ticketId, keyPair.second?.rfid!!)
|
|
|
}
|
|
|
}
|
|
|
}
|