|
|
@@ -41,6 +41,7 @@ import com.kongzue.dialogx.dialogs.PopTip
|
|
|
import com.sik.sikcore.SIKCore
|
|
|
import com.sik.sikcore.data.BeanUtils
|
|
|
import com.sik.sikcore.date.TimeUtils
|
|
|
+import com.sik.sikcore.extension.toJson
|
|
|
import com.sik.sikcore.thread.ThreadUtils
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.async
|
|
|
@@ -124,6 +125,7 @@ object BleBusinessManager {
|
|
|
// 只能在这里断开,不能全部断开
|
|
|
BleManager.getInstance().disconnect(bleBean.bleDevice)
|
|
|
BleConnectionManager.deviceList.removeIf { it.bleDevice.mac == bleBean.bleDevice.mac }
|
|
|
+ logger.info("断开连接发钥匙:${bleBean.bleDevice.mac}")
|
|
|
// 打开钥匙卡扣
|
|
|
val keyBean = ModBusController.getKeyByMac(bleBean.bleDevice.mac)
|
|
|
if (keyBean == null) {
|
|
|
@@ -142,6 +144,7 @@ object BleBusinessManager {
|
|
|
bleBean.bleDevice.mac, false, 1
|
|
|
)
|
|
|
PopTip.build().tip(R.string.take_out_key)
|
|
|
+ connectExistsKey(listOf(bleBean.bleDevice.mac))
|
|
|
}
|
|
|
} else {
|
|
|
logger.error("切换工作模式失败 : ${bleBean.bleDevice.mac}")
|
|
|
@@ -327,6 +330,7 @@ object BleBusinessManager {
|
|
|
DeviceConst.DEVICE_TYPE_LOCK, updateBo?.ticketId
|
|
|
)
|
|
|
) {
|
|
|
+ logger.info("有钥匙待取但是对应的作业票的锁还有")
|
|
|
//todo 如果有钥匙待取但是对应的作业票的锁还有的,就不发
|
|
|
return
|
|
|
}
|
|
|
@@ -342,20 +346,15 @@ object BleBusinessManager {
|
|
|
false, currentModeEvent.bleBean.bleDevice.mac
|
|
|
)
|
|
|
LoadingEvent.sendLoadingEvent()
|
|
|
- //连上之后没有工作票要下发就断开 看是否还有设备等待连接并且连接数是否大于等于预期,没有就不断开,有就让路,一般是初始化的时候
|
|
|
- if (BleConnectionManager.hasConnectWait() && BleManager.getInstance().allConnectedDevice.size >= BleConst.MAX_KEY_CONNECT_COUNT) {
|
|
|
- BleManager.getInstance()
|
|
|
- .disconnect(currentModeEvent.bleBean.bleDevice)
|
|
|
- BleConnectionManager.deviceList.removeIf { it.bleDevice.mac == currentModeEvent.bleBean.bleDevice.mac }
|
|
|
- }
|
|
|
+ logger.info("作业票数据为空")
|
|
|
return@runOnIO
|
|
|
}
|
|
|
RepositoryManager.jobTicketRepo.getStepDetail(itBO.ticketId) {
|
|
|
- logger.info("步骤数据:${it}")
|
|
|
+ logger.info("步骤数据:${it.toJson()}")
|
|
|
val step = it?.firstOrNull { it.stepStatus == "0" }
|
|
|
- logger.info("当前步骤:${step}")
|
|
|
+ logger.info("当前步骤:${step.toJson()}")
|
|
|
RepositoryManager.jobTicketRepo.getTicketDetail(itBO.ticketId) { ticketDetail ->
|
|
|
- logger.info("步骤详情:${ticketDetail}")
|
|
|
+ logger.info("步骤详情:${ticketDetail.toJson()}")
|
|
|
val role =
|
|
|
ticketDetail?.ticketUserVOList?.filter { it.userRole == RoleEnum.JTLOCKER.roleKey }
|
|
|
?.find {
|
|
|
@@ -374,8 +373,10 @@ object BleBusinessManager {
|
|
|
currentModeEvent.bleBean.bleDevice.mac,
|
|
|
ticketDetail,
|
|
|
ticketDetail.ticketLockVOList?.filter {
|
|
|
- it.groupId == MainDomainData.deviceTakeTicketGroupBound[itBO.ticketId] && ticketDetail.ticketPointsVOList?.mapNotNull { it.lockId }
|
|
|
- ?.contains(it.lockId) != true
|
|
|
+ it.groupId == MainDomainData.deviceTakeTicketGroupBound[itBO.ticketId] &&
|
|
|
+ ticketDetail.ticketPointsVOList?.filter { it.groupId == MainDomainData.deviceTakeTicketGroupBound[itBO.ticketId] }
|
|
|
+ ?.mapNotNull { it.lockId }
|
|
|
+ ?.contains(it.lockId) != true
|
|
|
}
|
|
|
?.map { it.lockNfc }?.toMutableList(),
|
|
|
true
|
|
|
@@ -401,8 +402,6 @@ object BleBusinessManager {
|
|
|
)
|
|
|
LoadingEvent.sendLoadingEvent()
|
|
|
//连上之后没有工作票要下发就断开 看是否还有设备等待连接并且连接数是否大于等于预期,没有就不断开,有就让路,一般是初始化的时候
|
|
|
- BleManager.getInstance().disconnect(currentModeEvent.bleBean.bleDevice)
|
|
|
- BleConnectionManager.deviceList.removeIf { it.bleDevice.mac == currentModeEvent.bleBean.bleDevice.mac }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -535,6 +534,7 @@ object BleBusinessManager {
|
|
|
PopTip.build().tip(CommonUtils.getStr(R.string.continue_the_ticket))
|
|
|
BleManager.getInstance().disconnect(bleDevice)
|
|
|
BleConnectionManager.deviceList.removeIf { it.bleDevice.mac == bleDevice.mac }
|
|
|
+ logger.info("断开连接归还取消:${bleDevice.mac}")
|
|
|
// 打开卡扣,防止初始化的时候选择不处理钥匙导致无法使用
|
|
|
val dock = ModBusController.getDockByKeyMac(bleDevice.mac)
|
|
|
val keyBean = dock?.getKeyList()?.find { it.mac == bleDevice.mac }
|
|
|
@@ -817,7 +817,12 @@ object BleBusinessManager {
|
|
|
true,
|
|
|
mac,
|
|
|
ticketDetail,
|
|
|
- ticketDetail.ticketLockVOList?.filter { it.lockStatus != "2" && it.groupId == MainDomainData.deviceTakeTicketGroupBound[it.ticketId] }
|
|
|
+ ticketDetail.ticketLockVOList?.filter {
|
|
|
+ it.groupId == MainDomainData.deviceTakeTicketGroupBound[it.ticketId] &&
|
|
|
+ ticketDetail.ticketPointsVOList?.filter { it.groupId == MainDomainData.deviceTakeTicketGroupBound[it.ticketId] }
|
|
|
+ ?.mapNotNull { it.lockId }
|
|
|
+ ?.contains(it.lockId) != true
|
|
|
+ }
|
|
|
?.map { it.lockNfc }?.toMutableList(),
|
|
|
true
|
|
|
)
|
|
|
@@ -834,6 +839,12 @@ object BleBusinessManager {
|
|
|
* 分配钥匙
|
|
|
*/
|
|
|
fun handleGiveKey(deviceTakeUpdateBO: DeviceTakeUpdate) {
|
|
|
+ logger.info(
|
|
|
+ "取完锁开始发钥匙1:${
|
|
|
+ ModBusController.getKeyByRfid(deviceTakeUpdateBO.nfc).toJson()
|
|
|
+ }"
|
|
|
+ )
|
|
|
+ logger.info("取完锁开始发钥匙2:${BleConnectionManager.deviceList.toJson()}")
|
|
|
BleConnectionManager.getBleDeviceByMac(ModBusController.getKeyByRfid(deviceTakeUpdateBO.nfc)?.mac)
|
|
|
?.let {
|
|
|
BleConnectionManager.getCurrentStatus(
|
|
|
@@ -880,6 +891,7 @@ object BleBusinessManager {
|
|
|
}
|
|
|
}
|
|
|
} ?: run {
|
|
|
+ logger.info("根据钥匙的rfid没找到钥匙")
|
|
|
TipDialog.show(
|
|
|
msg = CommonUtils.getStr(R.string.key_take_error_tip).toString(), onConfirmClick = {
|
|
|
DeviceExceptionEvent.sendDeviceExceptionEvent(
|
|
|
@@ -892,8 +904,15 @@ object BleBusinessManager {
|
|
|
/**
|
|
|
* 连接一把存在的可连接的钥匙
|
|
|
*/
|
|
|
- fun connectExistsKey(exceptKeyMac: String) {
|
|
|
+ fun connectExistsKey(exceptKeyMac: List<String> = listOf()) {
|
|
|
ThreadUtils.runOnIO {
|
|
|
+ val connectedDevice = BleManager.getInstance().allConnectedDevice
|
|
|
+ if (connectedDevice.isNotEmpty() && connectedDevice.subtract(exceptKeyMac.toSet())
|
|
|
+ .isNotEmpty()
|
|
|
+ ) {
|
|
|
+ logger.info("已有钥匙连接")
|
|
|
+ return@runOnIO
|
|
|
+ }
|
|
|
// —— 串行请求1 & 2 ——
|
|
|
val slotsPage = DataBusiness.getSlotsPage()
|
|
|
val keyPage = DataBusiness.getKeyPage()
|
|
|
@@ -913,7 +932,7 @@ object BleBusinessManager {
|
|
|
}?.toMutableList() ?: mutableListOf(),
|
|
|
(keyPage?.records?.filter { it.exStatus == keyStatusList.find { d -> d.dictLabel == "异常" }?.dictValue }
|
|
|
?.map { it.keyNfc ?: "" }?.toMutableList() ?: mutableListOf()),
|
|
|
- mutableListOf(exceptKeyMac)
|
|
|
+ exceptKeyMac
|
|
|
)
|
|
|
}
|
|
|
}
|