import 'package:domain/entity/response/device_list_entity.dart'; import 'package:domain/entity/response/fiance_report_entity.dart'; import 'package:domain/entity/response/labour_report_entity.dart'; import 'package:domain/entity/response/staff_request_report_entity.dart'; import 'package:get/get.dart'; import 'package:plugin_platform/dio_export.dart'; import 'package:plugin_platform/http/http_provider.dart'; import 'package:plugin_platform/http/http_result.dart'; import 'package:shared/utils/util.dart'; import '../constants/api_constants.dart'; /// 报表与其他的相关数据 class OtherRepository extends GetxService { HttpProvider httpProvider; OtherRepository({required this.httpProvider}); // 雇主的设备列表 Future> fetchDeviceList({ required int curPage, CancelToken? cancelToken, }) async { //参数 Map params = {}; params["cur_page"] = curPage.toString(); params["page_size"] = "10"; final result = await httpProvider.requestNetResult( ApiConstants.apiDeviceList, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = DeviceListEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } //财务报表 Future> fetchReportFiance( String? startDate, String? endDate, { CancelToken? cancelToken, }) async { //参数 Map params = {}; if (Utils.isEmpty(startDate)) { params["start_date"] = startDate!; } if (Utils.isEmpty(endDate)) { params["end_date"] = endDate!; } final result = await httpProvider.requestNetResult( ApiConstants.apiReportFiance, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = FianceReportEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } //用工报表 Future> fetchReportLabour( String? startDate, String? endDate, { CancelToken? cancelToken, }) async { //参数 Map params = {}; if (Utils.isEmpty(startDate)) { params["start_date"] = startDate!; } if (Utils.isEmpty(endDate)) { params["end_date"] = endDate!; } final result = await httpProvider.requestNetResult( ApiConstants.apiReportLabour, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = LabourReportEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } //员工请求报表 Future> fetchReportStaffRequest( String? startDate, String? endDate, { CancelToken? cancelToken, }) async { //参数 Map params = {}; if (Utils.isEmpty(startDate)) { params["start_date"] = startDate!; } if (Utils.isEmpty(endDate)) { params["end_date"] = endDate!; } final result = await httpProvider.requestNetResult( ApiConstants.apiReportStaffRequest, params: params, cancelToken: cancelToken, ); if (result.isSuccess) { var jsonList = result.getListJson(); var list = jsonList?.map((e) { if (e is Map) { return StaffRequestReportEntity.fromJson(e); } else { return null; } }).toList(); return result.convert(list: list); } return result.convert(); } }