|
|
@@ -25,6 +25,7 @@ import com.grkj.iscs.modbus.DockBean
|
|
|
import com.grkj.iscs.modbus.ModBusController
|
|
|
import com.grkj.iscs.model.Constants
|
|
|
import com.grkj.iscs.model.Constants.PERMISSION_REQUEST_CODE
|
|
|
+import com.grkj.iscs.model.Constants.USER_TYPE_LOCKER
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_CARD
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_FINGERPRINT
|
|
|
import com.grkj.iscs.model.DeviceConst.DEVICE_TYPE_KEY
|
|
|
@@ -39,12 +40,10 @@ import com.grkj.iscs.model.bo.WorkTicketSendBO
|
|
|
import com.grkj.iscs.model.bo.WorkTicketSendBO.LockListBO
|
|
|
import com.grkj.iscs.model.eventmsg.CurrentModeMsg
|
|
|
import com.grkj.iscs.model.eventmsg.DeviceTakeUpdateMsg
|
|
|
-import com.grkj.iscs.model.eventmsg.GetTicketStatusMsg
|
|
|
import com.grkj.iscs.model.eventmsg.LoadingMsg
|
|
|
import com.grkj.iscs.model.eventmsg.MsgEvent
|
|
|
import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_CURRENT_MODE
|
|
|
import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_DEVICE_TAKE_UPDATE
|
|
|
-import com.grkj.iscs.model.eventmsg.MsgEventConstants.MSG_EVENT_GET_TICKET_STATUS
|
|
|
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
|
|
|
@@ -57,7 +56,6 @@ import com.grkj.iscs.util.SPUtils
|
|
|
import com.grkj.iscs.util.ToastUtils
|
|
|
import com.grkj.iscs.util.log.LogUtil
|
|
|
import com.grkj.iscs.view.base.BaseActivity
|
|
|
-import com.grkj.iscs.view.dialog.TipDialog
|
|
|
import pub.devrel.easypermissions.AfterPermissionGranted
|
|
|
|
|
|
/**
|
|
|
@@ -742,7 +740,7 @@ object BusinessManager {
|
|
|
/**
|
|
|
* 读取工作票完成情况
|
|
|
*/
|
|
|
- fun getTicketStatusBusiness(
|
|
|
+ private fun getTicketStatusBusiness(
|
|
|
mac: String,
|
|
|
isNeedLoading: Boolean = false
|
|
|
) {
|
|
|
@@ -1079,13 +1077,56 @@ object BusinessManager {
|
|
|
|
|
|
private fun handleCurrentMode(currentModeMsg: CurrentModeMsg) {
|
|
|
when (currentModeMsg.mode) {
|
|
|
+ // 工作模式
|
|
|
0x01.toByte() -> {
|
|
|
- // TODO 读工作票
|
|
|
+ // 读工作票
|
|
|
getTicketStatusBusiness(currentModeMsg.bleBean.bleDevice.mac)
|
|
|
}
|
|
|
+ // 待机模式
|
|
|
0x02.toByte() -> {
|
|
|
- // 暂无
|
|
|
+ // 根据情况看是否需要下发工作票
|
|
|
+ ModBusController.getKeyByMac(currentModeMsg.bleBean.bleDevice.mac)?.let { key ->
|
|
|
+ // 判断是否有待取的钥匙
|
|
|
+ val updateBo = mDeviceTakeList.find { it.deviceType == DEVICE_TYPE_KEY && key.rfid == it.nfc }
|
|
|
+ updateBo?.let { itBO ->
|
|
|
+ NetApi.getStepDetail(itBO.ticketId) {
|
|
|
+ var step = 0
|
|
|
+ it?.filter { it.stepStatus == "1" }?.maxByOrNull { it.stepIndex!! }?.stepIndex?.let {
|
|
|
+ step = it
|
|
|
+ }
|
|
|
+ NetApi.getTicketDetail(itBO.ticketId) { ticketDetail ->
|
|
|
+ val role = ticketDetail?.jobTicketUserList?.find {
|
|
|
+ it.userId == SPUtils.getLoginUser(MyApplication.instance?.applicationContext!!)?.userId && it.userType == USER_TYPE_LOCKER
|
|
|
+ }
|
|
|
+ if (role == null) {
|
|
|
+ ToastUtils.tip(R.string.you_are_not_locker_tip)
|
|
|
+ return@getTicketDetail
|
|
|
+ }
|
|
|
+ if (step == 4) { // 上锁工作票
|
|
|
+ NetApi.getTicketEquipDetail(itBO.ticketId) { equipDetail ->
|
|
|
+ sendTicketBusiness(
|
|
|
+ currentModeMsg.bleBean.bleDevice.mac,
|
|
|
+ ticketDetail,
|
|
|
+ equipDetail?.ticketLockVOList?.map { it.lockNfc }?.toMutableList(),
|
|
|
+ ActivityUtils.currentActivity() as BaseActivity<*>,
|
|
|
+ true
|
|
|
+ )
|
|
|
+ }
|
|
|
+ } else if (step == 7) { // 解锁工作票
|
|
|
+ sendTicketBusiness(
|
|
|
+ currentModeMsg.bleBean.bleDevice.mac,
|
|
|
+ ticketDetail,
|
|
|
+ null,
|
|
|
+ ActivityUtils.currentActivity() as BaseActivity<*>,
|
|
|
+ true
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ // 故障模式
|
|
|
0x03.toByte() -> {
|
|
|
// TODO 上报?
|
|
|
}
|