|
@@ -212,7 +212,8 @@ object BusinessManager {
|
|
|
|
|
|
|
|
MSG_EVENT_SWITCH_COLLECTION_UPDATE -> {
|
|
MSG_EVENT_SWITCH_COLLECTION_UPDATE -> {
|
|
|
ThreadUtils.runOnIO {
|
|
ThreadUtils.runOnIO {
|
|
|
- val switchStatus = NetApi.getDictData(DictAndSystemConstants.KEY_SWITCH_STATUS)
|
|
|
|
|
|
|
+ val switchStatus =
|
|
|
|
|
+ NetApi.getDictData(DictAndSystemConstants.KEY_SWITCH_STATUS)
|
|
|
val switchListReqVOS = ModBusController.getSwitchData().map {
|
|
val switchListReqVOS = ModBusController.getSwitchData().map {
|
|
|
SwitchListReqVO(
|
|
SwitchListReqVO(
|
|
|
it.idx.toString(),
|
|
it.idx.toString(),
|
|
@@ -240,8 +241,10 @@ object BusinessManager {
|
|
|
// —— 并行加载字典(或按需串行也行) ——
|
|
// —— 并行加载字典(或按需串行也行) ——
|
|
|
val slotStatus =
|
|
val slotStatus =
|
|
|
async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_STATUS) }
|
|
async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_STATUS) }
|
|
|
- val keyStatus = async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_KEY_STATUS) }
|
|
|
|
|
- val slotType = async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_TYPE) }
|
|
|
|
|
|
|
+ val keyStatus =
|
|
|
|
|
+ async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_KEY_STATUS) }
|
|
|
|
|
+ val slotType =
|
|
|
|
|
+ async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_TYPE) }
|
|
|
|
|
|
|
|
// 等待字典加载完成
|
|
// 等待字典加载完成
|
|
|
val slotStatusList = slotStatus.await()
|
|
val slotStatusList = slotStatus.await()
|
|
@@ -591,7 +594,11 @@ object BusinessManager {
|
|
|
)
|
|
)
|
|
|
ThreadUtils.runOnIO {
|
|
ThreadUtils.runOnIO {
|
|
|
val lockStatusReq =
|
|
val lockStatusReq =
|
|
|
- async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_PAD_LOCK_STATUS) }
|
|
|
|
|
|
|
+ async {
|
|
|
|
|
+ fetchDict<CommonDictRespVO>(
|
|
|
|
|
+ DictAndSystemConstants.KEY_PAD_LOCK_STATUS
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
var lockStatus = lockStatusReq.await()
|
|
var lockStatus = lockStatusReq.await()
|
|
|
NetApi.getIsLockPage { lockData ->
|
|
NetApi.getIsLockPage { lockData ->
|
|
|
//锁rfid未异常正常请求锁数据,关锁
|
|
//锁rfid未异常正常请求锁数据,关锁
|
|
@@ -790,8 +797,10 @@ object BusinessManager {
|
|
|
async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_PAD_LOCK_STATUS) }
|
|
async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_PAD_LOCK_STATUS) }
|
|
|
val slotStatus =
|
|
val slotStatus =
|
|
|
async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_STATUS) }
|
|
async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_STATUS) }
|
|
|
- val slotType = async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_TYPE) }
|
|
|
|
|
- val keyStatus = async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_KEY_STATUS) }
|
|
|
|
|
|
|
+ val slotType =
|
|
|
|
|
+ async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_SLOT_TYPE) }
|
|
|
|
|
+ val keyStatus =
|
|
|
|
|
+ async { fetchDict<CommonDictRespVO>(DictAndSystemConstants.KEY_KEY_STATUS) }
|
|
|
|
|
|
|
|
// 等待字典加载完成
|
|
// 等待字典加载完成
|
|
|
val lockStatusList = lockStatus.await()
|
|
val lockStatusList = lockStatus.await()
|
|
@@ -1371,9 +1380,11 @@ object BusinessManager {
|
|
|
|
|
|
|
|
// 判断workTicketGetBO里是否有未完成的
|
|
// 判断workTicketGetBO里是否有未完成的
|
|
|
ThreadUtils.runOnIO {
|
|
ThreadUtils.runOnIO {
|
|
|
- if (workTicketGetBO.hasFinished()) {
|
|
|
|
|
|
|
+ val finishedStatus = workTicketGetBO.hasFinished()
|
|
|
|
|
+ LogUtil.i("作业票结束情况:${finishedStatus}")
|
|
|
|
|
+ if (finishedStatus.first) {
|
|
|
Executor.delayOnMain(500) {
|
|
Executor.delayOnMain(500) {
|
|
|
- handleKeyReturn(bleDevice, workTicketGetBO)
|
|
|
|
|
|
|
+ handleKeyReturn(bleDevice, workTicketGetBO, finishedStatus.second)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 当前策略:作业票未完成禁止归还钥匙
|
|
// 当前策略:作业票未完成禁止归还钥匙
|
|
@@ -1395,86 +1406,99 @@ object BusinessManager {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private fun handleKeyReturn(bleDevice: BleDevice, workTicketGetBO: WorkTicketGetBO?) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * ticketFinished主要是后端的作业票是否已经结束,结束了,就直接修改状态就好了
|
|
|
|
|
+ */
|
|
|
|
|
+ private fun handleKeyReturn(
|
|
|
|
|
+ bleDevice: BleDevice,
|
|
|
|
|
+ workTicketGetBO: WorkTicketGetBO?,
|
|
|
|
|
+ ticketFinished: Boolean
|
|
|
|
|
+ ) {
|
|
|
val dock = ModBusController.getDockByKeyMac(bleDevice.mac)
|
|
val dock = ModBusController.getDockByKeyMac(bleDevice.mac)
|
|
|
val keyBean = dock?.getKeyList()?.find { it.mac == bleDevice.mac }
|
|
val keyBean = dock?.getKeyList()?.find { it.mac == bleDevice.mac }
|
|
|
keyBean?.let {
|
|
keyBean?.let {
|
|
|
ModBusController.controlKeyBuckle(false, keyBean.isLeft, dock.addr)
|
|
ModBusController.controlKeyBuckle(false, keyBean.isLeft, dock.addr)
|
|
|
}
|
|
}
|
|
|
- // 上报隔离点状态
|
|
|
|
|
- val keyNfc = ModBusController.getKeyByMac(bleDevice.mac)?.rfid
|
|
|
|
|
- workTicketGetBO?.data?.forEach { data ->
|
|
|
|
|
- val updateList = mutableListOf<LockPointUpdateReqVO>()
|
|
|
|
|
- data.dataList?.forEach { dataListDTO ->
|
|
|
|
|
- data.taskCode?.toLong()?.let {
|
|
|
|
|
- SPUtils.returnKey(it)
|
|
|
|
|
|
|
+ if (ticketFinished) {
|
|
|
|
|
+ switchReadyMode(bleDevice)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 上报隔离点状态
|
|
|
|
|
+ val keyNfc = ModBusController.getKeyByMac(bleDevice.mac)?.rfid
|
|
|
|
|
+ workTicketGetBO?.data?.forEach { data ->
|
|
|
|
|
+ val updateList = mutableListOf<LockPointUpdateReqVO>()
|
|
|
|
|
+ data.dataList?.forEach { dataListDTO ->
|
|
|
|
|
+ data.taskCode?.toLong()?.let {
|
|
|
|
|
+ SPUtils.returnKey(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ val updateVO = LockPointUpdateReqVO(
|
|
|
|
|
+ data.taskCode?.toLong(),
|
|
|
|
|
+ dataListDTO.infoRfidNo,
|
|
|
|
|
+ dataListDTO.equipRfidNo,
|
|
|
|
|
+ keyNfc!!,
|
|
|
|
|
+ dataListDTO.target,
|
|
|
|
|
+ dataListDTO.status
|
|
|
|
|
+ )
|
|
|
|
|
+ updateList.add(updateVO)
|
|
|
}
|
|
}
|
|
|
- val updateVO = LockPointUpdateReqVO(
|
|
|
|
|
- data.taskCode?.toLong(),
|
|
|
|
|
- dataListDTO.infoRfidNo,
|
|
|
|
|
- dataListDTO.equipRfidNo,
|
|
|
|
|
- keyNfc!!,
|
|
|
|
|
- dataListDTO.target,
|
|
|
|
|
- dataListDTO.status
|
|
|
|
|
- )
|
|
|
|
|
- updateList.add(updateVO)
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- sendLoadingEventMsg(null, false)
|
|
|
|
|
- ToastUtils.tip(R.string.key_return_success)
|
|
|
|
|
- if (CAN_RETURN) {
|
|
|
|
|
- // 上报点位钥匙绑定
|
|
|
|
|
- NetApi.updateLockPointBatch(updateList) { isSuccess, msg ->
|
|
|
|
|
- if (isSuccess || msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
|
|
- R.string.lock_nfc_lost
|
|
|
|
|
- )
|
|
|
|
|
- ) {
|
|
|
|
|
- data.taskCode?.toLong()?.let {
|
|
|
|
|
- sendEventMsg(
|
|
|
|
|
- MsgEvent(
|
|
|
|
|
- MSG_EVENT_UPDATE_TICKET_PROGRESS, UpdateTicketProgressMsg(it)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ sendLoadingEventMsg(null, false)
|
|
|
|
|
+ ToastUtils.tip(R.string.key_return_success)
|
|
|
|
|
+ if (CAN_RETURN) {
|
|
|
|
|
+ // 上报点位钥匙绑定
|
|
|
|
|
+ NetApi.updateLockPointBatch(updateList) { isSuccess, msg ->
|
|
|
|
|
+ if (isSuccess || msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
|
|
+ R.string.lock_nfc_lost
|
|
|
)
|
|
)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ data.taskCode?.toLong()?.let {
|
|
|
|
|
+ sendEventMsg(
|
|
|
|
|
+ MsgEvent(
|
|
|
|
|
+ MSG_EVENT_UPDATE_TICKET_PROGRESS,
|
|
|
|
|
+ UpdateTicketProgressMsg(it)
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ // 确认归还,切换为待机模式
|
|
|
|
|
+ switchReadyMode(bleDevice)
|
|
|
|
|
+ } else if (msg != MyApplication.instance?.applicationContext!!.getString(R.string.lock_nfc_lost)) {
|
|
|
|
|
+ SPUtils.saveUpdateLockPoint(MyApplication.instance!!, updateList)
|
|
|
}
|
|
}
|
|
|
- // 确认归还,切换为待机模式
|
|
|
|
|
- switchReadyMode(bleDevice)
|
|
|
|
|
- } else if (msg != MyApplication.instance?.applicationContext!!.getString(R.string.lock_nfc_lost)) {
|
|
|
|
|
- SPUtils.saveUpdateLockPoint(MyApplication.instance!!, updateList)
|
|
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- // 上报钥匙归还
|
|
|
|
|
- NetApi.updateKeyReturn(
|
|
|
|
|
- data.taskCode?.toLong()!!, keyNfc!!, MyApplication.instance!!.serialNo()
|
|
|
|
|
- ) { isSuccess, msg ->
|
|
|
|
|
- if (!isSuccess && msg != MyApplication.instance?.applicationContext!!.getString(
|
|
|
|
|
- R.string.ticket_lost
|
|
|
|
|
- )
|
|
|
|
|
- ) {
|
|
|
|
|
- SPUtils.saveUpdateKeyReturn(
|
|
|
|
|
- MyApplication.instance!!,
|
|
|
|
|
- UpdateKeyReturnBO(data.taskCode?.toLong()!!, keyNfc!!)
|
|
|
|
|
- )
|
|
|
|
|
- if (msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
|
|
|
|
+ // 上报钥匙归还
|
|
|
|
|
+ NetApi.updateKeyReturn(
|
|
|
|
|
+ data.taskCode?.toLong()!!, keyNfc!!, MyApplication.instance!!.serialNo()
|
|
|
|
|
+ ) { isSuccess, msg ->
|
|
|
|
|
+ if (!isSuccess && msg != MyApplication.instance?.applicationContext!!.getString(
|
|
|
R.string.ticket_lost
|
|
R.string.ticket_lost
|
|
|
)
|
|
)
|
|
|
) {
|
|
) {
|
|
|
- sendEventMsg(
|
|
|
|
|
- MsgEvent(
|
|
|
|
|
- MsgEventConstants.MSG_EVENT_TICKET_FINISHED,
|
|
|
|
|
- null
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ SPUtils.saveUpdateKeyReturn(
|
|
|
|
|
+ MyApplication.instance!!,
|
|
|
|
|
+ UpdateKeyReturnBO(data.taskCode?.toLong()!!, keyNfc!!)
|
|
|
)
|
|
)
|
|
|
|
|
+ if (msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
|
|
+ R.string.ticket_lost
|
|
|
|
|
+ )
|
|
|
|
|
+ ) {
|
|
|
|
|
+ sendEventMsg(
|
|
|
|
|
+ MsgEvent(
|
|
|
|
|
+ MsgEventConstants.MSG_EVENT_TICKET_FINISHED,
|
|
|
|
|
+ null
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SPUtils.saveUpdateLockPoint(MyApplication.instance!!, updateList)
|
|
|
|
|
+ SPUtils.saveUpdateKeyReturn(
|
|
|
|
|
+ MyApplication.instance!!,
|
|
|
|
|
+ UpdateKeyReturnBO(data.taskCode?.toLong()!!, keyNfc!!)
|
|
|
|
|
+ )
|
|
|
|
|
+ // 保存待发数据,切换为待机模式
|
|
|
|
|
+ switchReadyMode(bleDevice)
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- SPUtils.saveUpdateLockPoint(MyApplication.instance!!, updateList)
|
|
|
|
|
- SPUtils.saveUpdateKeyReturn(
|
|
|
|
|
- MyApplication.instance!!, UpdateKeyReturnBO(data.taskCode?.toLong()!!, keyNfc!!)
|
|
|
|
|
- )
|
|
|
|
|
- // 保存待发数据,切换为待机模式
|
|
|
|
|
- switchReadyMode(bleDevice)
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|