|
@@ -0,0 +1,455 @@
|
|
|
|
|
+package com.rc.httpcore.client.retrofit
|
|
|
|
|
+
|
|
|
|
|
+import com.rc.httpcore.HttpClient
|
|
|
|
|
+import com.rc.httpcore.HttpConfig
|
|
|
|
|
+import com.rc.httpcore.client.LabClient
|
|
|
|
|
+import com.rc.httpcore.exception.AICheckException
|
|
|
|
|
+import com.rc.httpcore.exception.NetException
|
|
|
|
|
+import com.rc.httpcore.vo.CommonRowsResponse
|
|
|
|
|
+import com.rc.httpcore.vo.request.*
|
|
|
|
|
+import com.rc.httpcore.vo.response.*
|
|
|
|
|
+import io.reactivex.Observable
|
|
|
|
|
+import okhttp3.MediaType
|
|
|
|
|
+import okhttp3.MultipartBody
|
|
|
|
|
+import okhttp3.RequestBody
|
|
|
|
|
+
|
|
|
|
|
+class LabRetrofit : LabClient {
|
|
|
|
|
+
|
|
|
|
|
+ private val apiService by lazy {
|
|
|
|
|
+ HttpClient.createRetrofitApi(ApiService::class.java)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private val signInCheckService by lazy {
|
|
|
|
|
+ HttpClient.createRetrofitApi(ApiService::class.java, HttpConfig.SIGN_IN_CHECK_BASE_URL)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 登录获取token
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun authOneLogin(): Observable<Boolean> {
|
|
|
|
|
+ val param = AccessTokenReq().apply {
|
|
|
|
|
+ username = "onecUser"
|
|
|
|
|
+ password = "admin123"
|
|
|
|
|
+ }
|
|
|
|
|
+ return apiService.authOneLogin(param)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ HttpClient.token = response.data?.access_token
|
|
|
|
|
+ return@map !HttpClient.token.isNullOrEmpty()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询APK版本
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 设备唯一编码
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun apkVersion(id: String): Observable<ApkInfoResp> {
|
|
|
|
|
+ return apiService.apkVersion(id)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上传APK更新状态
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param state 0:升级失败; 1:升级成功; 2:升级中
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun onepcApkUpdate(id: String, state: String): Observable<Boolean> {
|
|
|
|
|
+ return apiService.onepcApkUpdate(id, state)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实验室信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 设备唯一编码
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun laboratoryInfo(id: String): Observable<LaboratoryVo> {
|
|
|
|
|
+ return apiService.laboratoryInfo(id)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 危险源信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param 实验室Id、分页信息
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun hazardlist(param: HazardReq): Observable<List<LabHazardVo>> {
|
|
|
|
|
+ return apiService.hazardlist(param.subId, param.pageNum, param.pageSize)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response.rows
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 签到验证(进入)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param subId 实验室id
|
|
|
|
|
+ * @param username 学生卡编号
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun signInCheck(subId: String, username: String): Observable<SignInCheckResp> {
|
|
|
|
|
+ return apiService.signInCheck(subId, username)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 签到提交-人脸验证
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun signInFace(code: String, faceFeature: SignInReq?): Observable<String> {
|
|
|
|
|
+ return apiService.signInFace(code, faceFeature)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 签到-安全准入检测三合一
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun checkInAll(param: CheckInAllReq): Observable<Boolean> {
|
|
|
|
|
+ val fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), param.file)
|
|
|
|
|
+ val filePart = MultipartBody.Part.createFormData("file", param.file.name, fileBody)
|
|
|
|
|
+
|
|
|
|
|
+ val formMediaType = MediaType.parse("multipart/form-data")
|
|
|
|
|
+ val bodyPartMap = mutableMapOf<String, RequestBody>()
|
|
|
|
|
+ if (!param.id.isNullOrEmpty()) {
|
|
|
|
|
+ bodyPartMap["id"] = RequestBody.create(formMediaType, param.id)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!param.subId.isNullOrEmpty()) {
|
|
|
|
|
+ bodyPartMap["subId"] = RequestBody.create(formMediaType, param.subId)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return signInCheckService.checkInAll(bodyPartMap, filePart)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw AICheckException(response.code, response.msg, response.data)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 签到提交
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun signIn(id: String): Observable<Boolean> {
|
|
|
|
|
+ return apiService.signIn(id)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 签到提交-有跳过安全准入检测时使用
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun signInJump(id: String, code: String): Observable<Boolean> {
|
|
|
|
|
+ return apiService.signInJump(id, code)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 签到验证(离开)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param subId 实验室id
|
|
|
|
|
+ * @param username 学生卡编号
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun signOutCheck(subId: String, username: String): Observable<SignInCheckResp> {
|
|
|
|
|
+ return apiService.signOutCheck(subId, username)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 离开提交
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun signOut(code: String): Observable<Boolean> {
|
|
|
|
|
+ return apiService.signOut(code)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取实验室一体机可控制设备
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param subId 实验室id
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun controllerList(subId: String): Observable<List<LotDeviceVo>> {
|
|
|
|
|
+ return apiService.controllerList(subId)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 控制设备
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param 设备编号、命令
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun sendControllerCMD(param: ControllerCMD): Observable<Boolean> {
|
|
|
|
|
+ return apiService.sendControllerCMD(param.id, param.command)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实验室测点功能列表(首页-左侧看板)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param subId 实验室id
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun functionList(subId: String): Observable<List<LabBulletinBoardVo>> {
|
|
|
|
|
+ return apiService.functionList(subId)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实验室预警测点
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param subId 实验室id
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun warnList(subId: String): Observable<List<LabBulletinBoardVo>> {
|
|
|
|
|
+ return apiService.warnList(subId)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 人脸比对
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun faceCompare(param: FaceCompareReq): Observable<Boolean> {
|
|
|
|
|
+ return apiService.faceCompare(HttpConfig.BASE_PATH_FACE, param)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 心跳
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param num 设备唯一编码
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun heartbeat(num: String): Observable<Boolean> {
|
|
|
|
|
+ return apiService.heartbeat(num)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询实验室安全制度列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param type 1:学校制度 2:学院制度 3: 中心制度
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun safeBookList(type: String): Observable<List<SafeBook>> {
|
|
|
|
|
+ return apiService.safeBookList(type)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取实验室安全制度详细信息
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun safeBookDetail(id: String): Observable<SafeBook> {
|
|
|
|
|
+ return apiService.safeBookDetail(id)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 一体机查询危化品
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun hazardBookList(): Observable<List<HazardBook>> {
|
|
|
|
|
+ return apiService.hazardBookList()
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取危化品安全技术说明书详细信息
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun hazardBookDetail(id: String): Observable<HazardBook> {
|
|
|
|
|
+ return apiService.hazardBookDetail(id)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询实验室在线人员
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun onlineUser(param: OnLineUserReq): Observable<CommonRowsResponse<LabPersonVo>> {
|
|
|
|
|
+ return apiService.onlineUser(param)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实验室安全整改信息
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun checkMachineMsgList(subId: String): Observable<List<CheckMachineVo>> {
|
|
|
|
|
+ return apiService.checkMachineMsgList(subId)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实验室通知消息信息
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun contentMachineMsgList(subId: String): Observable<List<ContentMachineVo>> {
|
|
|
|
|
+ return apiService.contentMachineMsgList(subId)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return@map response.rows
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 实验室文化图
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 设备唯一编码
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun bannerImages(id: String): Observable<List<BannerImageBean>> {
|
|
|
|
|
+ return apiService.bannerImages(id)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 文字转语音
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun textParseVideo(text: String): Observable<SpeakInfo> {
|
|
|
|
|
+ return apiService.textParseVideo(HttpConfig.BASE_PATH_SPEAK, "50", "20", text)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if ("0" != response.result) {
|
|
|
|
|
+ throw NetException("1000", "转换异常")
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 物联控制权限验证
|
|
|
|
|
+ */
|
|
|
|
|
+ override fun lotInCheck(subId: String, username: String): Observable<String> {
|
|
|
|
|
+ return apiService.lotInCheck(subId, username)
|
|
|
|
|
+ .map { response ->
|
|
|
|
|
+ if (!response.isSuccess()) {
|
|
|
|
|
+ throw NetException(response.code, response.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ return@map response.data
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|