|
|
@@ -33,12 +33,16 @@ import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_ELEC_LOCK_BOARD
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_KEY
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_LOCK
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_PORTABLE
|
|
|
+import com.grkj.iscs.model.bo.DeviceTakeUpdateBO
|
|
|
import com.grkj.iscs.model.bo.WorkTicketGetBO
|
|
|
import com.grkj.iscs.model.bo.WorkTicketSendBO
|
|
|
import com.grkj.iscs.model.bo.WorkTicketSendBO.LockListBO
|
|
|
+import com.grkj.iscs.model.eventmsg.DeviceTakeUpdateMsg
|
|
|
import com.grkj.iscs.model.eventmsg.LoadingMsg
|
|
|
import com.grkj.iscs.model.eventmsg.MsgEvent
|
|
|
+import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_DEVICE_TAKE_UPDATE
|
|
|
import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_LOADING
|
|
|
+import com.grkj.iscs.model.vo.lock.LockTakeUpdateReqVO
|
|
|
import com.grkj.iscs.model.vo.ticket.LockPointUpdateReqVO
|
|
|
import com.grkj.iscs.model.vo.ticket.TicketDetailRespVO
|
|
|
import com.grkj.iscs.util.ActivityUtils
|
|
|
@@ -89,6 +93,9 @@ object BusinessManager {
|
|
|
return (NEED_AUTH && loginUser != null) || !NEED_AUTH
|
|
|
}
|
|
|
|
|
|
+ // 设备归还列表(需要报给后台的列表,等实际取完再上报)
|
|
|
+ val mDeviceTakeList = mutableListOf<DeviceTakeUpdateBO>()
|
|
|
+
|
|
|
/**
|
|
|
* 初始化消息总线
|
|
|
*/
|
|
|
@@ -101,6 +108,9 @@ object BusinessManager {
|
|
|
(ActivityUtils.currentActivity() as BaseActivity<*>).handleLoading(loadingMsg.isShow, loadingMsg.loadingText)
|
|
|
}
|
|
|
}
|
|
|
+ MSG_EVENT_DEVICE_TAKE_UPDATE -> {
|
|
|
+ handleDeviceTake(it.data as DeviceTakeUpdateMsg)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -181,6 +191,7 @@ object BusinessManager {
|
|
|
keyBean.mac?.let {
|
|
|
unregisterConnectListener(it)
|
|
|
}
|
|
|
+ mEventBus.postValue(MsgEvent(MSG_EVENT_DEVICE_TAKE_UPDATE, DeviceTakeUpdateMsg(0, keyBean.rfid)))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -206,6 +217,8 @@ object BusinessManager {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ mEventBus.postValue(MsgEvent(MSG_EVENT_DEVICE_TAKE_UPDATE, DeviceTakeUpdateMsg(1, lockBean.rfid)))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -963,4 +976,35 @@ object BusinessManager {
|
|
|
println("getTicketStatus fail")}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加待更新取出状态的设备
|
|
|
+ */
|
|
|
+ fun addDeviceTake(deviceType: Int, ticketId: Long, nfc: String?) {
|
|
|
+ mDeviceTakeList.removeIf { it.deviceType == deviceType && it.nfc == nfc }
|
|
|
+ mDeviceTakeList.add(DeviceTakeUpdateBO(deviceType, ticketId, nfc))
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun handleDeviceTake(deviceTakeUpdateBO: DeviceTakeUpdateMsg) {
|
|
|
+ when (deviceTakeUpdateBO.deviceType) {
|
|
|
+ // 钥匙
|
|
|
+ 0 -> {
|
|
|
+ val info = mDeviceTakeList.find { it.deviceType == 0 && it.nfc == deviceTakeUpdateBO.nfc }
|
|
|
+ NetApi.updateKeyTake(info?.ticketId!!, info.nfc!!, MyApplication.instance?.serialNo()!!) { isSuccess ->
|
|
|
+ if (isSuccess) {
|
|
|
+ mDeviceTakeList.removeIf { it.deviceType == 0 && it.nfc == info.nfc }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 挂锁
|
|
|
+ 1 -> {
|
|
|
+ val info = mDeviceTakeList.find { it.deviceType == 1 && it.nfc == deviceTakeUpdateBO.nfc }
|
|
|
+ NetApi.updateLockTake(mutableListOf(LockTakeUpdateReqVO(info?.ticketId, info?.nfc, MyApplication.instance?.serialNo()!!))) { isSuccess ->
|
|
|
+ if (isSuccess == true) {
|
|
|
+ mDeviceTakeList.removeIf { it.deviceType == 1 && it.nfc == info?.nfc }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|