import 'dart:io'; import 'package:domain/entity/response/uk_labour_request_review_detail_entity.dart'; import 'package:domain/entity/response/uk_labour_request_review_list_entity.dart'; import 'package:domain/entity/server_time.dart'; import 'package:get/get.dart'; import 'package:plugin_platform/platform_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/uk_lab_req_show_template_entity.dart'; import '../entity/response/uk_labour_request_detail_entity.dart'; import '../entity/response/uk_labour_request_preselect_addstaff_list_entity.dart'; import '../entity/response/uk_labour_request_preselected_list_entity.dart'; import '../entity/response/uk_labour_request_table_entity.dart'; import '../entity/response/uk_labour_review_status_entity.dart'; /// 用工请求相关 class UkLabourRepository extends GetxService { HttpProvider httpProvider; UkLabourRepository({required this.httpProvider}); /// 获取用工请求的主列表 Future> fetchLabourRequestList( String? keyword, String? startDate, String? endDate, String? statusId, String? departmentId, { required int curPage, CancelToken? cancelToken, }) async { //参数 Map params = {}; params["cur_page"] = curPage.toString(); params["page_size"] = "20"; if (!Utils.isEmpty(keyword)) { params["job_title"] = keyword!; } if (!Utils.isEmpty(startDate)) { params["job_start"] = startDate!; } if (!Utils.isEmpty(endDate)) { params["job_end"] = endDate!; } if (!Utils.isEmpty(statusId)) { params["co_status"] = statusId!; } if (!Utils.isEmpty(departmentId)) { params["co_department_id"] = departmentId!; } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestList, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourRequestTableEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// 根据ID获取主列表的Item数据,用于刷新Item Future> fetchItemByRequestId( String? requestId, { CancelToken? cancelToken, }) async { //参数 Map params = {}; params["cur_page"] = "1"; params["page_size"] = "1"; if (!Utils.isEmpty(requestId)) { params["request_id"] = requestId!; } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestList, params: params, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourRequestTableEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// 添加用工的选项 Future> fetchLabourRequestAddOption({ CancelToken? cancelToken, }) async { final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestAddOption, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourRequestDetailEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// 根据模板id 回显 详情页相关数据 Future> fetchLabourRequestShowTemplateData( String templateId, { CancelToken? cancelToken, }) async { Map params = {}; params['template_id'] = templateId; final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestTemplateShowUK, params: params, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabReqShowTemplateEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// 获取labourequest 详情 Future> fetchLabourRequestDetail( String? requestId, { CancelToken? cancelToken, }) async { //参数 Map params = {}; if (!Utils.isEmpty(requestId)) { params["request_id"] = requestId!; } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestEditDetail, params: params, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourRequestDetailEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// lab-request 的编辑用工请求发布 Future editLabourRequestSubmit({ String? requestId, String? templateId, String? jobStart, String? jobEnd, String? departmentId, String? needNum, String? salaryBy, String? repeatDateStr, String? amount, String? certificate, // 多个逗号隔开 String? challenge25, String? vehicle, // 多个逗号隔开 String? description, String? employmentType, String? eventName, String? eventType, String? passengers, String? estRevenue, String? position, String? estCost, dynamic? attUrl, String? videoText, dynamic? videoCover, dynamic? video, dynamic? otherImage, dynamic? otherDocument, CancelToken? cancelToken, }) async { //参数 Map params = {}; params['request_id'] = requestId ?? ""; params['template_id'] = templateId ?? ""; params['job_start'] = jobStart ?? ""; params['job_end'] = jobEnd ?? ""; params['need_num'] = needNum ?? ""; if (!Utils.isEmpty(departmentId)) { params["co_department_id"] = departmentId!; } params['salary_by'] = salaryBy ?? ""; if (!Utils.isEmpty(amount)) { params["amount"] = amount!; } if(!Utils.isEmpty(certificate)){ params["certificate"] = certificate!; } if(!Utils.isEmpty(challenge25)){ params["challenge_25"] = challenge25!; } if(!Utils.isEmpty(vehicle)){ params["vehicle"] = vehicle!; } if(!Utils.isEmpty(repeatDateStr)) { params["select"] = repeatDateStr!; } params['description'] = description ?? ""; params['employment_type'] = employmentType ?? ""; params['event_name'] = eventName ?? ""; params['event_type'] = eventType ?? ""; params['passengers'] = passengers ?? ""; params['est_revenue'] = estRevenue ?? ""; params['position'] = position ?? ""; params['est_cost'] = estCost ?? ""; //可能是file 也可能是 url Map filePathParams = {}; // 判断 http 或者 https 开头 if(Utils.isNotEmpty(attUrl)){ if(attUrl!.startsWith("http") || attUrl!.startsWith("https")){ params['att_url'] = attUrl; }else { filePathParams['att_url'] = attUrl; } } // 视频部分的参数 params['video_text'] = videoText ?? ""; //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(videoCover)){ if(videoCover!.startsWith("http") || videoCover!.startsWith("https")){ params['video_cover'] = videoCover; }else { filePathParams['video_cover'] = videoCover; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(video)){ if(video!.startsWith("http") || video!.startsWith("https")){ params['video'] = video; }else { filePathParams['video'] = video; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(otherImage)){ if(otherImage!.startsWith("http") || otherImage!.startsWith("https")){ params['other_image'] = otherImage; }else { filePathParams['other_image'] = otherImage; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(otherDocument)){ if(otherDocument!.startsWith("http") || otherDocument!.startsWith("https")){ params['other_document'] = otherDocument; }else { filePathParams['other_document'] = otherDocument; } } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestEditSubmit, method: HttpMethod.POST, params: params, paths: filePathParams, networkDebounce: true, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list return result.convert(); } return result.convert(); } /// lab-request-review 的编辑用工请求发布 Future editLabourRequestReviewSubmit({ String? requestId, String? templateId, String? jobStart, String? jobEnd, String? departmentId, String? needNum, String? salaryBy, String? repeatDateStr, String? amount, String? certificate, // 多个逗号隔开 String? challenge25, String? vehicle, // 多个逗号隔开 String? description, String? employmentType, String? eventName, String? eventType, String? passengers, String? estRevenue, String? position, String? estCost, dynamic? attUrl, String? videoText, dynamic? videoCover, dynamic? video, dynamic? otherImage, dynamic? otherDocument, CancelToken? cancelToken, }) async { //参数 Map params = {}; params['request_id'] = requestId ?? ""; params['template_id'] = templateId ?? ""; params['job_start'] = jobStart ?? ""; params['job_end'] = jobEnd ?? ""; params['need_num'] = needNum ?? ""; if (!Utils.isEmpty(departmentId)) { params["co_department_id"] = departmentId!; } params['salary_by'] = salaryBy ?? ""; if (!Utils.isEmpty(amount)) { params["amount"] = amount!; } if(!Utils.isEmpty(certificate)){ params["certificate"] = certificate!; } if(!Utils.isEmpty(challenge25)){ params["challenge_25"] = challenge25!; } if(!Utils.isEmpty(vehicle)){ params["vehicle"] = vehicle!; } if(!Utils.isEmpty(repeatDateStr)) { params["select"] = repeatDateStr!; } params['description'] = description ?? ""; params['employment_type'] = employmentType ?? ""; params['event_name'] = eventName ?? ""; params['event_type'] = eventType ?? ""; params['passengers'] = passengers ?? ""; params['est_revenue'] = estRevenue ?? ""; params['position'] = position ?? ""; params['est_cost'] = estCost ?? ""; //可能是file 也可能是 url Map filePathParams = {}; // 判断 http 或者 https 开头 if(Utils.isNotEmpty(attUrl)){ if(attUrl!.startsWith("http") || attUrl!.startsWith("https")){ params['att_url'] = attUrl; }else { filePathParams['att_url'] = attUrl; } } // 视频部分的参数 params['video_text'] = videoText ?? ""; //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(videoCover)){ if(videoCover!.startsWith("http") || videoCover!.startsWith("https")){ params['video_cover'] = videoCover; }else { filePathParams['video_cover'] = videoCover; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(video)){ if(video!.startsWith("http") || video!.startsWith("https")){ params['video'] = video; }else { filePathParams['video'] = video; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(otherImage)){ if(otherImage!.startsWith("http") || otherImage!.startsWith("https")){ params['other_image'] = otherImage; }else { filePathParams['other_image'] = otherImage; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(otherDocument)){ if(otherDocument!.startsWith("http") || otherDocument!.startsWith("https")){ params['other_document'] = otherDocument; }else { filePathParams['other_document'] = otherDocument; } } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestReViewEditUK, method: HttpMethod.POST, params: params, paths: filePathParams, networkDebounce: true, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list return result.convert(); } return result.convert(); } /// lab-request 的新增 labourequest用工请求发布 Future addLabourRequestSubmit({ String? templateId, String? jobDate, String? jobStart, String? jobEnd, String? departmentId, String? needNum, String? salaryBy, String? repeatDateStr, String? amount, String? certificate, // 多个逗号隔开 String? challenge25, String? vehicle, // 多个逗号隔开 String? jobApplyPreId, String? description, String? employmentType, String? eventName, String? eventType, String? passengers, String? estRevenue, String? position, String? estCost, dynamic? attUrl, String? videoText, dynamic? videoCover, dynamic? video, dynamic? otherImage, dynamic? otherDocument, CancelToken? cancelToken, }) async { //参数 Map params = {}; params['template_id'] = templateId ?? ""; params['job_date'] = jobDate ?? ""; params['start_time'] = jobStart ?? ""; params['end_time'] = jobEnd ?? ""; params['need_num'] = needNum ?? ""; if (!Utils.isEmpty(departmentId)) { params["co_department_id"] = departmentId!; } params['salary_by'] = salaryBy ?? ""; if(!Utils.isEmpty(repeatDateStr)){ params["select"] = repeatDateStr!; } if(!Utils.isEmpty(jobApplyPreId)){ params["job_apply_pre_id"] = jobApplyPreId!; } if (!Utils.isEmpty(amount)) { params["amount"] = amount!; } if(!Utils.isEmpty(certificate)){ params["certificate"] = certificate!; } if(!Utils.isEmpty(challenge25)){ params["challenge_25"] = challenge25!; } if(!Utils.isEmpty(vehicle)){ params["vehicle"] = vehicle!; } params['description'] = description ?? ""; params['employment_type'] = employmentType ?? ""; params['event_name'] = eventName ?? ""; params['event_type'] = eventType ?? ""; params['passengers'] = passengers ?? ""; params['est_revenue'] = estRevenue ?? ""; params['position'] = position ?? ""; params['est_cost'] = estCost ?? ""; //可能是file 也可能是 url Map filePathParams = {}; // 判断 http 或者 https 开头 if(Utils.isNotEmpty(attUrl)){ if(attUrl!.startsWith("http") || attUrl!.startsWith("https")){ params['att_url'] = attUrl; }else { filePathParams['att_url'] = attUrl; } } // 视频部分的参数 params['video_text'] = videoText ?? ""; //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(videoCover)){ if(videoCover!.startsWith("http") || videoCover!.startsWith("https")){ params['video_cover'] = videoCover; }else { filePathParams['video_cover'] = videoCover; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(video)){ if(video!.startsWith("http") || video!.startsWith("https")){ params['video'] = video; }else { filePathParams['video'] = video; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(otherImage)){ if(otherImage!.startsWith("http") || otherImage!.startsWith("https")){ params['other_image'] = otherImage; }else { filePathParams['other_image'] = otherImage; } } //可能是file 也可能是 url // 判断 http 或者 https 开头 if(Utils.isNotEmpty(otherDocument)){ if(otherDocument!.startsWith("http") || otherDocument!.startsWith("https")){ params['other_document'] = otherDocument; }else { filePathParams['other_document'] = otherDocument; } } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestAddSubmit, method: HttpMethod.POST, params: params, paths: filePathParams, networkDebounce: true, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list return result.convert(); } return result.convert(); } /// 用工请求 快速复制 Future quickCopyLabourRequestSubmit( String? requestId, // 格式[Y-m-d] String? jobDate, //格式[H:m] String? startTime, //格式[H:m] String? endTime, { CancelToken? cancelToken, }) async { //参数 Map params = {}; params['request_id'] = requestId ?? ""; params['job_date'] = jobDate ?? ""; params['start_time'] = startTime ?? ""; params['end_time'] = endTime ?? ""; final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestQuickCopyUK, method: HttpMethod.POST, params: params, networkDebounce: true, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list return result.convert(); } return result.convert(); } /// 获取 labourequest preselected 列表 Future> fetchLabourRequestPreselectedList( String reQuestId, { required int curPage, CancelToken? cancelToken, }) async { //参数 Map params = {}; params["cur_page"] = curPage.toString(); params["page_size"] = "20"; if (!Utils.isEmpty(reQuestId)) { params["request_id"] = reQuestId; } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestPreSelectListUK, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourRequestPreselectedListEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// 预选人-添加员工的列表 Future> fetchtPreselectedAddStaffList( String? keyWord, String? reQuestId, { required int curPage, CancelToken? cancelToken, }) async { //参数 Map params = {}; params["cur_page"] = curPage.toString(); params["page_size"] = "20"; if (!Utils.isEmpty(keyWord)) { params["keyword"] = keyWord!; } if (!Utils.isEmpty(reQuestId)) { params["request_id"] = reQuestId!; } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestPreSelectAddStaffListUK, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourRequestPreselectAddstaffListEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } //// 添加预选员工 Future labourRequestPreselectedAddStaffSubmit( String reQuestId, String staffIds, { CancelToken? cancelToken, }) async { //参数 Map params = {}; params['request_id'] = reQuestId ?? ""; params['staff_ids'] = staffIds ?? ""; final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestPreSelectAddBatchUK, method: HttpMethod.POST, params: params, networkDebounce: true, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list return result.convert(); } return result.convert(); } /// 删除预选员工 Future labourRequestPreselectedDelete( String selectedId, { CancelToken? cancelToken, }) async { //参数 Map params = {}; params['selected_id'] = selectedId ?? ""; final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestPreSelectDeleteUK, method: HttpMethod.POST, params: params, networkDebounce: true, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list return result.convert(); } return result.convert(); } /// labourequest -review ------------ /// 获取用工请求审核的主列表 Future> fetchLabourRequestReViewList({ String? keyword, String? startDate, String? endDate, String? departmentId, required int curPage, CancelToken? cancelToken, }) async { //参数 Map params = {}; params["cur_page"] = curPage.toString(); params["page_size"] = "20"; if (!Utils.isEmpty(keyword)) { params["job_title"] = keyword!; } if (!Utils.isEmpty(startDate)) { params["job_start"] = startDate!; } if (!Utils.isEmpty(endDate)) { params["job_end"] = endDate!; } if (!Utils.isEmpty(departmentId)) { params["co_department_id"] = departmentId!; } final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestReViewListUK, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourRequestReviewListEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } /// labourrequest -review 批量审核(批量同意/批量拒绝) Future labourRequestReviewBatchSubmit( { // 多个Record Ids以逗号分隔 String? recordIds, // 审核类型Type【approve|reject】 String? type, CancelToken? cancelToken, }) async { //参数 Map params = {}; params['record_ids'] = recordIds ?? ""; params['type'] = type ?? ""; final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestReViewBatchSubmitUK, method: HttpMethod.POST, params: params, networkDebounce: true, isShowLoadingDialog: true, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list return result.convert(); } return result.convert(); } /// 用工审核的审核流程列表 Future> fetchLabourReviewStatusView( String? requestId, { CancelToken? cancelToken, }) async { //参数 Map params = {}; params['request_id'] = requestId ?? ""; final result = await httpProvider.requestNetResult( ApiConstants.apiLabourRequestStateWorkFlow, params: params, cancelToken: cancelToken, ); //根据返回的结果,封装原始数据为Bean/Entity对象 if (result.isSuccess) { //重新赋值data或list final json = result.getDataJson(); var data = UkLabourReviewStatusEntity.fromJson(json!); //重新赋值data或list return result.convert(data: data); } return result.convert(); } }