| | |
| | | import cn.flightfeather.thirdappmodule.common.net.ResultObserver |
| | | import cn.flightfeather.thirdappmodule.common.net.RetrofitFactory |
| | | import cn.flightfeather.thirdappmodule.httpservice.EvaluationService |
| | | import cn.flightfeather.thirdappmodule.model.bean.BaseResponse |
| | | import cn.flightfeather.thirdappmodule.repository.dao.EvaluationDao |
| | | import io.reactivex.Observable |
| | | import io.reactivex.functions.BiFunction |
| | |
| | | * 评分相关数据操作 |
| | | */ |
| | | class EvaluationRepository { |
| | | companion object { |
| | | @JvmStatic |
| | | val instance: EvaluationRepository by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { EvaluationRepository()} |
| | | } |
| | | private val retrofit = RetrofitFactory.instance.retrofit |
| | | private val evaluationDao = EvaluationDao() |
| | | |
| | | |
| | | /** |
| | | * 获取评估总规则 |
| | | */ |
| | | fun getEvaluationRule( |
| | | provinceCode: String, cityCode: String, |
| | | districtCode: String, sceneTypeId: Byte, resultCallBack: ResultCallBack<List<Evaluationrule>>) { |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 根据巡查记录id获取评估总分 |
| | | */ |
| | | fun getEvaluation(inspectionGuid: String, resultCallBack: ResultCallBack<List<Evaluation>>) { |
| | | retrofit.create(EvaluationService::class.java) |
| | | .findByInspectionId(inspectionGuid).enqueue(ResponseBodyCallBack(resultCallBack)) |
| | | } |
| | | |
| | | /** |
| | | * 根据场景id获取评估总分 |
| | | */ |
| | | fun getEvaluationByScene(sceneId: String, page: Int = 1, pageSize: Int = 4, resultCallBack: ResultCallBack<List<Evaluation>>) { |
| | | val service = retrofit.create(EvaluationService::class.java).getEvaluationListByScene(sceneId, page, pageSize) |
| | | |
| | | RetrofitFactory.executeResult(service, object : ResultObserver<BaseResponse<List<Evaluation>>>() { |
| | | override fun onPage(current: Int, total: Int) { |
| | | super.onPage(current, total) |
| | | resultCallBack.onPage(current, total) |
| | | } |
| | | |
| | | override fun onSuccess(result: BaseResponse<List<Evaluation>>?) { |
| | | resultCallBack.onSuccess(result?.data) |
| | | } |
| | | |
| | | override fun onFailure(e: Throwable, isNetWorkError: Boolean) { |
| | | resultCallBack.onFailure() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | fun getRuleItem(evaluationruleGuid: String, subTaskGuid: String,resultCallBack: ResultCallBack<ArrayList<EvaluationsubruleVo>>) { |
| | | val dbService = evaluationDao.getEvaluationSubRule(evaluationruleGuid).map { |
| | | val list = it.map { |