package com.xw.yunwei.net import com.blankj.utilcode.util.GsonUtils import com.xw.common.net.BaseHttpManager.Companion.getBody import com.xw.common.net.interceptAwait import com.xw.yunwei.model.CheckInMissionPointInfo import com.xw.yunwei.model.CheckRecordModel import com.xw.yunwei.model.CruiseCheckInMissionInfo import com.xw.yunwei.model.CruiseCheckInOperationInfo import com.xw.yunwei.model.CruiseCheckInOperationResult import com.xw.yunwei.model.MaintainRecordModel import com.xw.yunwei.model.SiteModel import com.xw.yunwei.model.UploadModel class WorkRepository(private val api: WorkApi) { suspend fun querySites(map: Map) = api.querySites(getBody(map)).interceptAwait() suspend fun queryCars(map: Map) = api.queryCars(getBody(map)).interceptAwait() suspend fun vehicleDispatchAccept(map: Map) = api.vehicleDispatchAccept(getBody(map)).interceptAwait() suspend fun vehicleDispatchDeparture(map: Map) = api.vehicleDispatchDeparture(getBody(map)).interceptAwait() suspend fun unlockByType(map: Map) = api.unlockByType(getBody(map)).interceptAwait() suspend fun saveRepair(map: Map) = api.saveRepair(getBody(map)).interceptAwait() suspend fun saveReturnRepair(map: Map) = api.saveReturnRepair(getBody(map)).interceptAwait() suspend fun cleanCar(map: Map) = api.cleanCar(getBody(map)).interceptAwait() suspend fun savePreparation(body: MaintainRecordModel) = api.savePreparation(body).interceptAwait() suspend fun getRecord(map: Map) = api.getRecord(getBody(map)).interceptAwait() suspend fun startCharging(map: Map) = api.startCharging(getBody(map)).interceptAwait() suspend fun stopCharging(map: Map) = api.stopCharging(getBody(map)).interceptAwait() suspend fun saveDetection(body: CheckRecordModel) = api.saveDetection(body).interceptAwait() suspend fun queryCarInfo(id: Long) = api.queryCarInfo(id).interceptAwait() suspend fun getDesc(type: Int) = api.getDesc(type).interceptAwait() suspend fun startCheck(id: Long) = api.startCheck(id).interceptAwait() suspend fun queryChargingStatus(id: Long) = api.queryChargingStatus(id).interceptAwait() suspend fun queryRepairStatus(id: Long) = api.queryRepairStatus(id).interceptAwait() suspend fun preparationDetail(id: Long) = api.preparationDetail(id).interceptAwait() suspend fun chargingDetail(id: Long) = api.chargingDetail(id).interceptAwait() suspend fun detectionDetail(id: Long) = api.detectionDetail(id).interceptAwait() suspend fun repairDetail(id: Long) = api.repairDetail(id).interceptAwait() suspend fun cleanDetail(id: Long) = api.cleanDetail(id).interceptAwait() suspend fun queryPolicyInfoByVid(id: Long) = api.queryPolicyInfoByVid(id).interceptAwait() suspend fun applyPolicyInformation(id: Long) = api.applyPolicyInformation(id).interceptAwait() suspend fun getFenceByCode(cityCode: String) = api.getFenceByCode(cityCode).interceptAwait() suspend fun queryArea() = api.queryArea().interceptAwait() /* 现场情况上报 */ suspend fun addPointSituationReport( work: Boolean, model: SiteModel, sceneDescription: String, scenePhoto: MutableList, ): Boolean { val map = mapOf( "fieldSituation" to if (work) 1 else 2,//现场情况(1=正常,2=异常) "pointId" to model.id.toString(),//点位id "sceneDescription" to sceneDescription,//现场情况说明 "scenePhoto" to GsonUtils.toJson(scenePhoto),//现场照片JSON数组 ) api.addPointSituationReport(getBody(map)).interceptAwait() return true } /* 获取个人中心巡游打卡任务 */ suspend fun getMyCruiseCheckInMissionInfo(): CruiseCheckInMissionInfo? { return api.getMyCruiseCheckInMissionInfo().interceptAwait() } /* 获取巡游打卡定位列表 */ suspend fun getCheckInMissionPointsList(id: String): List? { return api.getCheckInMissionPointsList(id).interceptAwait() } /* 巡游打卡5秒钟轮询上传实时位置 */ suspend fun uploadRealTimePosition( id: String, latitude: Double, longitude: Double, ): CruiseCheckInOperationInfo? { val map = mapOf( "id" to id, "latitude" to latitude, "longitude" to longitude, ) return api.uploadRealTimePosition(getBody(map)).interceptAwait() } /* 巡游打卡操作 */ suspend fun saveCruiseCheckInRecord( locationId: String, work: Boolean, sceneDescription: String, scenePhoto: MutableList, ): CruiseCheckInOperationResult? { val map = mapOf( "checkLocationId" to locationId,//打卡点位id "fieldSituation" to if (work) 1 else 2,//现场情况(1=正常,2=拥堵) "sceneDescription" to sceneDescription,//现场情况说明 "scenePhoto" to GsonUtils.toJson(scenePhoto),//现场照片JSON数组 ) return api.saveCruiseCheckInRecord(getBody(map)).interceptAwait() } /* 获取打卡结果详情 */ suspend fun getCruiseCheckInRecordInfo( id: String, locationId: String ): CruiseCheckInOperationResult? { return api.getCruiseCheckInRecordInfo(id, locationId).interceptAwait() } }