|
|
@@ -452,7 +452,7 @@ object BusinessManager {
|
|
|
}
|
|
|
|
|
|
DeviceConst.DOCK_TYPE_COLLECT -> {
|
|
|
- ModBusController.switchStatus(bytes){}
|
|
|
+ ModBusController.switchStatus(bytes) {}
|
|
|
}
|
|
|
}
|
|
|
Executor.delayOnMain(200) {
|
|
|
@@ -671,9 +671,13 @@ object BusinessManager {
|
|
|
state = 1
|
|
|
onConfirm.invoke()
|
|
|
}
|
|
|
+ dlg.setOnCancelListener {
|
|
|
+ state = 2
|
|
|
+ onCancel.invoke()
|
|
|
+ }
|
|
|
dlg.setOnDismissListener {
|
|
|
if (state == 0) {
|
|
|
- onConfirm.invoke()
|
|
|
+ onCancel.invoke()
|
|
|
}
|
|
|
}
|
|
|
dlg.show()
|
|
|
@@ -825,16 +829,6 @@ object BusinessManager {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
- val actualLockCount = lockMap.values.sumBy { it.size }
|
|
|
- // 如果锁不够,提前清空并立刻返回
|
|
|
- if (actualLockCount < needLockCount) {
|
|
|
- ToastUtils.tip(
|
|
|
- MyApplication.instance!!.getString(R.string.lock_is_not_enough)
|
|
|
- )
|
|
|
- callBack(null, mutableMapOf())
|
|
|
- return@runOnMain
|
|
|
- }
|
|
|
-
|
|
|
// —— 如果需钥匙,再请求并计算 ——
|
|
|
var keyPair: Pair<Byte, DockBean.KeyBean?>? = null
|
|
|
if (isNeedKey) {
|
|
|
@@ -848,11 +842,6 @@ object BusinessManager {
|
|
|
?.map { it.keyNfc ?: "" }?.toMutableList() ?: mutableListOf()
|
|
|
)
|
|
|
}
|
|
|
- if (keyPair == null) {
|
|
|
- ToastUtils.tip(
|
|
|
- MyApplication.instance!!.getString(R.string.no_available_key)
|
|
|
- )
|
|
|
- }
|
|
|
}
|
|
|
// —— 全部计算完毕,在主线程一次性回调 ——
|
|
|
callBack(keyPair, lockMap)
|
|
|
@@ -867,13 +856,6 @@ object BusinessManager {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 获取开关量数据
|
|
|
- */
|
|
|
- fun getSwitchData(): MutableList<DockBean.SwitchBean> {
|
|
|
- return ModBusController.getSwitchData()
|
|
|
- }
|
|
|
-
|
|
|
/****************************************** 蓝牙 ******************************************/
|
|
|
/******************************************蓝牙通用准备******************************************/
|
|
|
|
|
|
@@ -983,6 +965,13 @@ object BusinessManager {
|
|
|
)
|
|
|
}
|
|
|
} else {
|
|
|
+ //如果连接在待发列表则断开连接,重新使用归还队列连接之后检查
|
|
|
+ if (BleSendDispatcher.isConnected(mac)) {
|
|
|
+ BleSendDispatcher.scheduleDisconnect(mac)
|
|
|
+ BleReturnDispatcher.submit(mac) {
|
|
|
+ getTicketStatusBusiness(mac, isNeedLoading)
|
|
|
+ }
|
|
|
+ }
|
|
|
if (isNeedLoading) sendEventMsg(
|
|
|
MsgEvent(
|
|
|
MSG_EVENT_LOADING, LoadingMsg(false, null, false)
|
|
|
@@ -1492,6 +1481,7 @@ object BusinessManager {
|
|
|
val keyBean = ModBusController.getKeyByMac(bleDevice.mac)
|
|
|
mDeviceTakeList.find { it.deviceType == DEVICE_TYPE_KEY && it.nfc == keyBean?.rfid }
|
|
|
?.let { itKey ->
|
|
|
+ LogUtil.i("检查到存在待取钥匙:${itKey}")
|
|
|
sendLoadingEventMsg(
|
|
|
MyApplication.instance?.applicationContext!!.getString(
|
|
|
R.string.ble_connecting
|
|
|
@@ -1554,9 +1544,6 @@ object BusinessManager {
|
|
|
val updateList = mutableListOf<LockPointUpdateReqVO>()
|
|
|
data.dataList?.filter { it.closed == 1 && it.status == it.target }
|
|
|
?.forEach { dataListDTO ->
|
|
|
- data.taskCode?.toLong()?.let {
|
|
|
- SPUtils.returnKey(it)
|
|
|
- }
|
|
|
val updateVO = LockPointUpdateReqVO(
|
|
|
data.taskCode?.toLong(),
|
|
|
dataListDTO.infoRfidNo,
|
|
|
@@ -1570,39 +1557,20 @@ object BusinessManager {
|
|
|
|
|
|
sendLoadingEventMsg(null, false)
|
|
|
if (CAN_RETURN) {
|
|
|
+ //如果需要上报的点位数据为空则直接上报钥匙归还
|
|
|
+ if (updateList.isEmpty()) {
|
|
|
+ mDeviceTakeList.removeIf { it.nfc == keyBean?.rfid }
|
|
|
+ // 上报钥匙归还
|
|
|
+ keyReturn(data.taskCode?.toLong()!!, keyNfc)
|
|
|
+ switchReadyMode(bleDevice)
|
|
|
+ return@forEach
|
|
|
+ }
|
|
|
// 上报点位钥匙绑定
|
|
|
NetApi.updateLockPointBatch(updateList) { isSuccess, msg, code ->
|
|
|
LogUtil.i("还锁操作:${isSuccess},${msg},${code}")
|
|
|
if (isSuccess) {
|
|
|
// 上报钥匙归还
|
|
|
- NetApi.updateKeyReturn(
|
|
|
- data.taskCode?.toLong()!!,
|
|
|
- keyNfc!!,
|
|
|
- MyApplication.instance!!.serialNo()
|
|
|
- ) { isSuccess, msg, code ->
|
|
|
- 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(
|
|
|
- R.string.ticket_lost
|
|
|
- )
|
|
|
- ) {
|
|
|
- sendEventMsg(
|
|
|
- MsgEvent(
|
|
|
- MsgEventConstants.MSG_EVENT_TICKET_FINISHED, null
|
|
|
- )
|
|
|
- )
|
|
|
- }
|
|
|
- ToastUtils.tip(R.string.key_return_success)
|
|
|
- } else {
|
|
|
- ToastUtils.tip(R.string.key_return_success)
|
|
|
- }
|
|
|
- }
|
|
|
+ keyReturn(data.taskCode?.toLong()!!, keyNfc)
|
|
|
data.taskCode?.toLong()?.let {
|
|
|
sendEventMsg(
|
|
|
MsgEvent(
|
|
|
@@ -1657,6 +1625,34 @@ object BusinessManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 钥匙归还
|
|
|
+ */
|
|
|
+ private fun keyReturn(ticketId: Long, keyNfc: String) {
|
|
|
+ NetApi.updateKeyReturn(
|
|
|
+ ticketId,
|
|
|
+ keyNfc,
|
|
|
+ MyApplication.instance!!.serialNo()
|
|
|
+ ) { isSuccess, msg, code ->
|
|
|
+ if (!isSuccess) {
|
|
|
+ if (msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
+ R.string.ticket_lost
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ sendEventMsg(
|
|
|
+ MsgEvent(
|
|
|
+ MsgEventConstants.MSG_EVENT_TICKET_FINISHED, null
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ SPUtils.clearUpdateKeyReturn(MyApplication.instance!!)
|
|
|
+ ToastUtils.tip(R.string.key_return_success)
|
|
|
+ } else {
|
|
|
+ ToastUtils.tip(R.string.key_return_success)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 处理虚拟钥匙取出,如果作业的全部点位已经上锁更新钥匙的状态使用
|
|
|
*/
|
|
|
@@ -1677,13 +1673,7 @@ object BusinessManager {
|
|
|
NetApi.updateKeyReturn(
|
|
|
taskCode, keyNfc, MyApplication.instance!!.serialNo()
|
|
|
) { isSuccess, msg, code ->
|
|
|
- if (!isSuccess && msg != MyApplication.instance?.applicationContext!!.getString(
|
|
|
- R.string.ticket_lost
|
|
|
- )
|
|
|
- ) {
|
|
|
- SPUtils.saveUpdateKeyReturn(
|
|
|
- MyApplication.instance!!, UpdateKeyReturnBO(taskCode, keyNfc)
|
|
|
- )
|
|
|
+ if (!isSuccess) {
|
|
|
if (msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
R.string.ticket_lost
|
|
|
)
|
|
|
@@ -1694,6 +1684,7 @@ object BusinessManager {
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
+ SPUtils.clearUpdateKeyReturn(MyApplication.instance!!)
|
|
|
} else {
|
|
|
done()
|
|
|
sendEventMsg(
|
|
|
@@ -1813,12 +1804,14 @@ object BusinessManager {
|
|
|
return
|
|
|
}
|
|
|
sendLoadingEventMsg(null, false)
|
|
|
- SPUtils.takeKey(info.ticketId)
|
|
|
NetApi.updateKeyTake(
|
|
|
info.ticketId, info.nfc, MyApplication.instance?.serialNo()!!
|
|
|
) { isSuccess ->
|
|
|
if (isSuccess) {
|
|
|
- mDeviceTakeList.removeIf { it.deviceType == DEVICE_TYPE_KEY && it.nfc == info.nfc }
|
|
|
+ mDeviceTakeList.removeIf {
|
|
|
+ it.deviceType == DEVICE_TYPE_KEY && it.nfc == info.nfc && it.ticketId ==
|
|
|
+ info.ticketId
|
|
|
+ }
|
|
|
sendEventMsg(
|
|
|
MsgEvent(
|
|
|
MSG_EVENT_UPDATE_TICKET_PROGRESS,
|
|
|
@@ -2155,14 +2148,7 @@ object BusinessManager {
|
|
|
itData.ticketId, itData.keyNfc, context.serialNo()
|
|
|
) { isSuccess, msg, code ->
|
|
|
count++
|
|
|
- if (isSuccess || msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
- R.string.ticket_lost
|
|
|
- )
|
|
|
- ) {
|
|
|
- returnList.remove(itData)
|
|
|
- getBleBeanByRfid(itData.keyNfc)?.bleDevice?.let {
|
|
|
- switchReadyMode(it)
|
|
|
- }
|
|
|
+ if (!isSuccess) {
|
|
|
if (msg == MyApplication.instance?.applicationContext!!.getString(
|
|
|
R.string.ticket_lost
|
|
|
)
|
|
|
@@ -2173,15 +2159,7 @@ object BusinessManager {
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
- }
|
|
|
- if (count == itemsToRemove.size) {
|
|
|
- if (returnList.isEmpty()) {
|
|
|
- SPUtils.clearUpdateKeyReturn(context)
|
|
|
- } else {
|
|
|
- returnList.forEach {
|
|
|
- SPUtils.saveUpdateKeyReturn(context, it)
|
|
|
- }
|
|
|
- }
|
|
|
+ SPUtils.clearUpdateKeyReturn(MyApplication.instance!!)
|
|
|
}
|
|
|
}
|
|
|
}
|