package com.grkj.iscs_mc.util

import com.grkj.iscs_mc.MyApplication
import com.grkj.iscs_mc.model.Token
import com.grkj.iscs_mc.model.UrlConsts
import com.grkj.iscs_mc.model.vo.card.CardInfoRespVO
import com.grkj.iscs_mc.model.vo.dept.DeptListRespVO
import com.grkj.iscs_mc.model.vo.home.HomePageDataRespVO
import com.grkj.iscs_mc.model.vo.inspection.InsertCheckRecordReqVO
import com.grkj.iscs_mc.model.vo.inspection.InspectionCheckTableDataRespVO
import com.grkj.iscs_mc.model.vo.inspection.LatestInspectionPlanRespVO
import com.grkj.iscs_mc.model.vo.key.KeyInfoRespVO
import com.grkj.iscs_mc.model.vo.lock.LockInfoRespVO
import com.grkj.iscs_mc.model.vo.machinery.MachineryDetailRespVO
import com.grkj.iscs_mc.model.vo.machinery.MachineryPageRespVO
import com.grkj.iscs_mc.model.vo.material.MaterialBorrowReturnReqVO
import com.grkj.iscs_mc.model.vo.material.MaterialDetailRespVO
import com.grkj.iscs_mc.model.vo.material.MaterialInstructionListRespVO
import com.grkj.iscs_mc.model.vo.material.MaterialListRespVO
import com.grkj.iscs_mc.model.vo.material.MaterialPropertyPageRespVO
import com.grkj.iscs_mc.model.vo.material.MaterialPropertyValuePageRespVO
import com.grkj.iscs_mc.model.vo.material.MaterialTypePageRespVO
import com.grkj.iscs_mc.model.vo.replacement.ManualReplacementListRespVO
import com.grkj.iscs_mc.model.vo.sop.SopInfoRespVO
import com.grkj.iscs_mc.model.vo.sop.SopPageRespVO
import com.grkj.iscs_mc.model.vo.ticket.LockPointUpdateReqVO
import com.grkj.iscs_mc.model.vo.ticket.LotoMapRespVO
import com.grkj.iscs_mc.model.vo.ticket.StepDetailRespVO
import com.grkj.iscs_mc.model.vo.ticket.TicketDetailMonitorRespVO
import com.grkj.iscs_mc.model.vo.ticket.TicketDetailRespVO
import com.grkj.iscs_mc.model.vo.ticket.TicketEquipDetailRespVO
import com.grkj.iscs_mc.model.vo.ticket.TicketPageRespVO
import com.grkj.iscs_mc.model.vo.ticket.TicketTypeRespVO
import com.grkj.iscs_mc.model.vo.ticket.TicketUserReqVO
import com.grkj.iscs_mc.model.vo.ticket.WorkstationTicketListRespVO
import com.grkj.iscs_mc.model.vo.user.RoleListRespVO
import com.grkj.iscs_mc.model.vo.user.UserInfoRespVO
import com.grkj.iscs_mc.model.vo.user.UserListRespVO

/**
 * 网络请求
 */
object NetApi {
    /**
     * 登录
     */
    fun login(username: String, password: String, callBack: (Boolean?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.SIGN_IN,
            false,
            mapOf(
                "username" to username,
                "password" to password
            ),
            { res, _, _ ->
                res?.let {
                    val newToken = it.toBean(Token::class.java)
                    newToken.saveToSp(MyApplication.instance!!.applicationContext)
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = false)
    }

    /**
     * 退出登录
     */
    fun logout() {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.LOGOUT,
            false,
            mapOf<String, String>(),
            { res, _, _ ->
                SPUtils.clearLoginUser(MyApplication.instance!!.applicationContext)
                Token.clear(MyApplication.instance!!.applicationContext)
            }, isGet = true, isAuth = false
        )
    }

    /**
     * 刷卡登录
     */
    fun cardLogin(cardNfc: String, callBack: (Boolean?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.LOGIN_CARD,
            false,
            mapOf(
                "cardNfc" to cardNfc
            ),
            { res, _, _ ->
                res?.let {
                    val token: String? = getRefBean(it)
                    Token(token!!, 0).saveToSp(MyApplication.instance!!.applicationContext)
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = false)
    }

    /**
     * 获取SOP分页
     */
    fun getSopPage(pages: Int, size: Int, machineryId: Long, sopType: Int, callBack: (SopPageRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.SOP_PAGE,
            false,
            mapOf(
                "pages" to pages,
                "size" to size,
                "machineryId" to machineryId,
                "sopType" to sopType
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true)
    }

    /**
     * 获取工作票类型
     */
    @Deprecated("不使用")
    fun getTicketType(callBack: (MutableList<TicketTypeRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.TICKET_TYPE,
            false,
            mapOf<String,String>(),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true)
    }

    /**
     * 获取一个自动编号
     */
    @Deprecated("不使用")
    fun getAutoCode(type: String, callBack: (String?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.AUTO_CODE + "/" +type,
            false,
            mapOf<String, String>(),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(it.toString())
                }
            }, isGet = true, isAuth = true)
    }

    /**
     * 获取SOP详情
     */
    @Deprecated("不使用")
    fun getSopInfo(sopId: Long, callBack: (SopInfoRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.SOP_INFO,
            false,
            mapOf(
                "sopId" to sopId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true)
    }

    /**
     * 获取用户列表
     *
     * @param unitId 9：玛氏内部
     * @param roleId 3：上锁人  4：共锁人
     */
    fun getUserList(
        pageNum: Int,
        pageSize: Int,
        workstationId: Long? = null,
        roleId: Long? = null,
        unitId: Long? = null,
        callBack: (UserListRespVO?) -> Unit
    ) {
        val map: MutableMap<String, Any> = mutableMapOf("pageNum" to pageNum, "pageSize" to pageSize)
        workstationId?.let {
            map["workstationId"] = it
        }
        roleId?.let {
            map["roleId"] = it
        }
        unitId?.let {
            map["unitId"] = it
        }
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.USER_LIST,
            false,
            map,
            { res, _, _ ->
                res?.let {
                    callBack.invoke(it.toBean(UserListRespVO::class.java))
                }
            }, isGet = true, isAuth = true)
    }

    /**
     * 获取部门列表
     */
    @Deprecated("不使用")
    fun getDeptList(pageNum: Int, pageSize: Int, callBack: (MutableList<DeptListRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.DEPT_LIST,
            false,
            mapOf(
                "pageNum" to pageNum,
                "pageSize" to pageSize
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 创建工作票
     *
     * @return 工作票ID
     */
    fun createTicket(sopId: Long, callBack: (Long?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.CREATE_TICKET,
            false,
            mapOf(
                "sopId" to sopId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 获取工作票分页
     */
    @Deprecated("不使用")
    fun getTicketPage(pageNum: Int, pageSize: Int, userId: Long, ticketStatus: Int?, callBack: (TicketPageRespVO?) -> Unit) {
        val map = mutableMapOf(
            "pageNum" to pageNum,
            "pageSize" to pageSize,
            "userId" to userId
        )
        if (ticketStatus != null) {
            map["ticketStatus"] = ticketStatus
        }
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.PAGE_TICKET,
            false,
            map,
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 获取作业票详细信息
     */
    fun getTicketDetail(ticketId: Long, callBack: (TicketDetailRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.DETAIL_TICKET,
            false,
            mapOf("ticketId" to ticketId),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 根据登录用户获取刷卡信息
     */
    fun getCardInfoByLoginUser(callBack: (CardInfoRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.CARD_INFO_BY_LOGIN_USER,
            false,
            mapOf<String, String>(),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 根据nfc编号获取刷卡信息
     */
    fun getCardInfoByNfc(cardNfc: String, callBack: (CardInfoRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.CARD_INFO_BY_CARD_NFC,
            false,
            mapOf("cardNfc" to cardNfc),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                } ?: run {
                    callBack.invoke(null)
                }
            }, isGet = true, isAuth = true
        )
   }

    /**
     * 通过nfc编号获取key信息
     */
    fun getKeyInfo(keyNfc: String, callBack: (KeyInfoRespVO?) -> Unit) {
        val loginUser = SPUtils.getLoginUser(MyApplication.instance?.applicationContext!!)
        NetHttpManager.getInstance().doRequestNet(
            if (loginUser == null) {
                UrlConsts.KEY_INFO_BY_NFC_WITHOUT_AUTH
            } else {
                UrlConsts.KEY_INFO_BY_NFC
            },
            false,
            mapOf("nfc" to keyNfc),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = loginUser != null
        )
    }

    /**
     * 通过nfc编号获取lock信息，暂时用来判断是否是公司的锁
     */
    fun getLockInfo(lockNfc: String, callBack: (LockInfoRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.LOCK_INFO_BY_NFC,
            false,
            mapOf("nfc" to lockNfc),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                } ?: let {
                    callBack.invoke(null)
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 挂锁上锁时更新数据，更新挂锁和哪个隔离点进行了绑定
     */
    fun updateLockPoint(ticketId: Long, lockNfc: String, pointNfc: String, callBack: (Boolean?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.LOCK_POINT_UPDATE,
            false,
            mapOf(
                "ticketId" to ticketId,
                "lockNfc" to lockNfc,
                "pointNfc" to pointNfc
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 获取作业票和关联数据
     */
    fun getTicketEquipDetail(ticketId: Long, callBack: (TicketEquipDetailRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.TICKET_EQUIP_DETAIL,
            false,
            mapOf("ticketId" to ticketId),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 取出钥匙
     */
    fun updateKeyTake(ticketId: Long, keyNfc: String, serialNumber: String, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.KEY_TAKE_UPDATE,
            false,
            mapOf(
                "ticketId" to ticketId,
                "keyNfc" to keyNfc,
                "serialNumber" to serialNumber
            ),
            { res, _, _ ->
                callBack.invoke(res != null)
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 更新作业票进度
     */
    fun updateTicketProgress(ticketId: Long, userId: Long, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.TICKET_UPDATE_PROGRESS,
            false,
            mapOf(
                "ticketId" to ticketId,
                "userId" to userId
            ),
            { res, _, _ ->
                callBack.invoke(res != null)
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 批量更新作业票下隔离点的上锁解锁状况
     */
    fun updateLockPointBatch(list: MutableList<LockPointUpdateReqVO>, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.LOCK_POINT_UPDATE_BATCH,
            false,
            mapOf(
                "list" to list
            ),
            { res, _, _ ->
                callBack.invoke(res != null)
            }, isGet = false, isAuth =true
        )
    }

    /**
     * 根据角色获取人员列表
     */
    @Deprecated("不使用")
    fun getRoleList(pageNum: Int, pageSize: Int, roleKey: String, callBack: (RoleListRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.ROLE_LIST,
            false,
            mapOf(
                "pageNum" to pageNum,
                "pageSize" to pageSize,
                "roleKey" to roleKey
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(it.toBean(RoleListRespVO::class.java))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 正在进行中的作业票列表
     */
    fun getWorkstationTicketList(pages: Int, size: Int, callBack: (MutableList<WorkstationTicketListRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.WORKSTATION_TICKET_LIST,
            false,
            mapOf(
                "pages" to pages,
                "size" to size
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 获取工艺分页
     */
    fun getMachineryPage(pages: Int, size: Int, workstationId: Long, callBack: (MachineryPageRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MACHINERY_PAGE,
            false,
            mapOf(
                "pages" to pages,
                "size" to size,
                "workstationId" to workstationId,
                "machineryType" to "工艺"
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 获取八大步骤详细
     */
    fun getStepDetail(ticketId: Long, callBack: (MutableList<StepDetailRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.TICKET_STEP,
            false,
            mapOf(
                "ticketId" to ticketId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 获取设备工艺详细信息
     */
    fun getMachineryDetail(machineryId: Long, callBack: (MachineryDetailRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MACHINERY_DETAIL,
            false,
            mapOf(
                "machineryId" to machineryId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 获取电柜map解析数据
     */
    fun getLotoMapData(lotoId: Long, callBack: (MutableList<LotoMapRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.LOTO_MAP,
            false,
            mapOf(
                "lotoId" to lotoId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
   }

    /**
     * 取消作业票
     */
    fun cancelTicket(ticketId: Long, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.CANCEL_TICKET,
            false,
            mapOf(
                "ticketId" to ticketId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 结束作业票
     */
    fun finishTicket(ticketId: Long, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.FINISH_TICKET,
            false,
            mapOf(
                "ticketId" to ticketId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 新增/更新作业票人员
     */
    fun updateTicketUser(ticketId: Long, userList: MutableList<TicketUserReqVO>, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.UPDATE_TICKET_USER,
            false,
            mapOf(
                "ticketId" to ticketId,
                "ticketUserDTOList" to userList
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 作业票详情监控
     */
    fun getTicketDetailMonitor(ticketId: Long, callBack: (TicketDetailMonitorRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.TICKET_DETAIL_MONITOR,
            false,
            mapOf(
                "ticketId" to ticketId
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 八大步骤执行
     */
    fun updateStep(stepId: Long, stepStatus: String, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.UPDATE_STEP,
            false,
            mapOf(
                "stepId" to stepId,
                "stepStatus" to stepStatus
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 共锁人上锁/解锁
     */
    fun updateColockerStatus(ticketId: Long, cardNfc: String, jobStatus: String, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.UPDATE_COLOCKER_STATUS,
            false,
            mapOf(
                "ticketId" to ticketId,
                "cardNfc" to cardNfc,
                "jobStatus" to jobStatus
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 获取用户信息
     */
    fun getUserInfo(callBack: (UserInfoRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.GET_USER_INFO,
            false,
            mapOf<String, String>(),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(it.toBean(UserInfoRespVO::class.java))
                }
            }, isGet = true, isAuth = true
        )
    }

    /********************************物资柜********************************/

    /**
     * 获取物资柜物品分类及分类下物资数量和列表
     */
    fun getMaterialList(cabinetCode: String, callBack: (MutableList<MaterialListRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_LIST,
            false,
            mapOf(
                "cabinetCode" to cabinetCode
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 通过RFID列表获取批量物资信息
     */
    fun getMaterialDetailListByRfid(list: MutableList<String>, callBack: (MutableList<MaterialDetailRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_DETAIL_LIST_BY_RFID,
            false,
            mapOf(
                "list" to list
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = false, isAuth = false
        )
    }

    /**
     * 通过RFID获取物资信息
     */
    fun getMaterialDetailByRfid(rfid: String, callBack: (MaterialDetailRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_DETAIL_BY_RFID,
            false,
            mapOf(
                "rfid" to rfid
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 打开物资柜
     *
     * @param openType 开门类型(0-物资领取归还 1-物资检查 2-物资更换)
     */
    fun openCabinet(cabinetCode: String, openType: Int, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.OPEN_CABINET,
            false,
            mapOf(
                "cabinetCode" to cabinetCode,
                "openType" to openType
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 关闭物资柜
     */
    fun closeCabinet(cabinetCode: String, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.CLOSE_CABINET,
            false,
            mapOf(
                "cabinetCode" to cabinetCode
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 借出/归还物资
     */
    fun materialBorrowReturn(list: MutableList<MaterialBorrowReturnReqVO>, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_BORROW_RETURN,
            false,
            mapOf(
                "list" to list
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 查询物资使用说明
     */
    fun getMaterialInstructionList(callBack: (MutableList<MaterialInstructionListRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_INSTRUCTION_LIST,
            false,
            mapOf<String, String>(),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 主界面数据
     */
    fun getHomePageData(cabinetCode: String, callBack: (HomePageDataRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.HOME_PAGE_DATA,
            false,
            mapOf(
                "cabinetCode" to cabinetCode
            ),
            { res, _, _ ->
                res?.let {
                    callBack(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 在某个柜子上我的最近一次物资检查计划
     */
    fun getLatestInspectionPlan(cabinetCode: String, callBack: (LatestInspectionPlanRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.LATEST_INSPECTION_PLAN,
            false,
            mapOf(
                "cabinetCode" to cabinetCode
            ),
            { res, _, _ ->
                res?.let {
                    callBack(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 获取物资检查表数据
     */
    fun getCheckTableData(planId: Long, cabinetCode: String, callBack: (InspectionCheckTableDataRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.CHECK_TABLE_DATA,
            false,
            mapOf(
                "planId" to planId,
                "cabinetCode" to cabinetCode
            ),
            { res, _, _ ->
                res?.let {
                    callBack(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 提交物资检查记录
     */
    fun insertCheckRecord(list: MutableList<InsertCheckRecordReqVO>, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.INSERT_CHECK_RECORD,
            false,
            mapOf(
                "list" to list
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }

    /**
     * 获取物资柜手动更换物资类型和异常数量和物资信息
     */
    fun getManualReplacementList(cabinetCode: String, callBack: (MutableList<ManualReplacementListRespVO>?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MANUAL_REPLACEMENT_LIST,
            false,
            mapOf(
                "cabinetCode" to cabinetCode
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 查询物资类型-分页
     */
    fun getMaterialTypePage(current: Int, size: Int, callBack: (MaterialTypePageRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_TYPE_PAGE,
            false,
            mapOf(
                "current" to current,
                "size" to size
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            }, isGet = true, isAuth = true
        )
    }

    /**
     * 查询物资属性项-分页
     */
    @Deprecated("已废弃")
    fun getMaterialPropertyPage(current: Int, size: Int, callBack: (MaterialPropertyPageRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_PROPERTY_PAGE,
            false,
            mapOf(
                "current" to current,
                "size" to size
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            },isGet = true, isAuth = true
        )
    }

    /**
     * 查询物资属性值-分页
     */
    fun getMaterialPropertyValuePage(current: Int, size: Int, callBack: (MaterialPropertyValuePageRespVO?) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.MATERIAL_PROPERTY_VALUE_PAGE,
            false,
            mapOf(
                "current" to current,
                "size" to size
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(getRefBean(it))
                }
            },isGet = true, isAuth = true
        )
    }

    /**
     * 检查签名
     */
    fun insertSign(planId: Long, cabinetCode: String, signatureImg: String, callBack: (Boolean) -> Unit) {
        NetHttpManager.getInstance().doRequestNet(
            UrlConsts.INSERT_SIGN,
            false,
            mapOf(
                "planId" to planId,
                "cabinetCode" to cabinetCode,
                "signatureImg" to signatureImg
            ),
            { res, _, _ ->
                res?.let {
                    callBack.invoke(true)
                } ?: run {
                    callBack.invoke(false)
                }
            }, isGet = false, isAuth = true
        )
    }
}