123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- 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/log_utils.dart';
- import 'package:shared/utils/util.dart';
- import '../constants/api_constants.dart';
- import '../entity/response/labour_report_v_n_entity.dart';
- import '../entity/response/staff_report_v_n_entity.dart';
- /// 报表与其他的相关数据
- class OtherRepository extends GetxService {
- HttpProvider httpProvider;
- OtherRepository({required this.httpProvider});
- // 雇主的设备列表
- Future<HttpResult<DeviceListEntity>> fetchDeviceList({
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> 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<DeviceListEntity>(data: data);
- }
- return result.convert();
- }
- //财务报表
- Future<HttpResult<FianceReportEntity>> fetchReportFiance(
- String? startDate,
- String? endDate, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (Utils.isNotEmpty(startDate)) {
- params["start_date"] = startDate!;
- }
- if (Utils.isNotEmpty(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<FianceReportEntity>(data: data);
- }
- return result.convert();
- }
- //用工报表
- Future<HttpResult<LabourReportEntity>> fetchReportLabour(
- String? startDate,
- String? endDate, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (Utils.isNotEmpty(startDate)) {
- params["start_date"] = startDate!;
- }
- if (Utils.isNotEmpty(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<LabourReportEntity>(data: data);
- }
- return result.convert();
- }
- //员工请求报表
- Future<HttpResult<StaffRequestReportEntity?>> fetchReportStaffRequest(
- String? startDate,
- String? endDate, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (Utils.isNotEmpty(startDate)) {
- params["start_date"] = startDate!;
- }
- if (Utils.isNotEmpty(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<String, dynamic>) {
- return StaffRequestReportEntity.fromJson(e);
- } else {
- return null;
- }
- }).toList();
- return result.convert<StaffRequestReportEntity?>(list: list);
- }
- return result.convert<StaffRequestReportEntity>();
- }
- /// 越南的员工报表
- Future<HttpResult<StaffReportVNEntity>> fetchStaffReportVN(
- String? startDate,
- String? endDate, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (Utils.isNotEmpty(startDate)) {
- params["start_date"] = startDate!;
- }
- if (Utils.isNotEmpty(endDate)) {
- params["end_date"] = endDate!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiReportStaffRequest,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = StaffReportVNEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<StaffReportVNEntity>(data: data);
- }
- return result.convert();
- }
- /// 越南的用工报表
- Future<HttpResult<LabourReportVNEntity>> fetchReportLabourVN(
- String? startDate,
- String? endDate, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (Utils.isNotEmpty(startDate)) {
- params["start_date"] = startDate!;
- }
- if (Utils.isNotEmpty(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 = LabourReportVNEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<LabourReportVNEntity>(data: data);
- }
- return result.convert();
- }
- }
|