123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734 |
- import 'dart:typed_data';
- import 'package:domain/entity/response/job_list_add_staff_entity.dart';
- import 'package:domain/entity/response/job_list_applied_edit_entity.dart';
- import 'package:domain/entity/response/job_list_applied_info_entity.dart';
- import 'package:domain/entity/response/job_list_applied_staff_list_entity.dart';
- import 'package:domain/entity/response/job_list_applied_staff_search_entity.dart';
- import 'package:domain/entity/response/job_list_detail_entity.dart';
- import 'package:domain/entity/response/job_list_entity.dart';
- import 'package:domain/entity/response/job_list_index_entity.dart';
- import 'package:domain/entity/response/job_list_remark_view_entity.dart';
- import 'package:domain/entity/response/staff_detail_entity.dart';
- import 'package:domain/entity/response/staff_labour_history_entity.dart';
- import 'package:domain/entity/response/staff_remark_history_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';
- import '../entity/response/attendance_entity.dart';
- import '../entity/response/check_success_entity.dart';
- import '../entity/response/job_list_applied_work_flow_entity.dart';
- /// 工作相关
- class JobRepository extends GetxService {
- HttpProvider httpProvider;
- JobRepository({required this.httpProvider});
- /// 获取当前酒店的考勤成员列表
- Future<HttpResult<AttendanceEntity>> fetchAttendanceList(
- String? keyword,
- String? startDate,
- String? endDate, {
- CancelToken? cancelToken,
- }) async {
- Map<String, String> params = {};
- params["cur_page"] = "1";
- params["page_size"] = "9999";
- if (!Utils.isEmpty(keyword)) {
- params["keyword"] = keyword!;
- }
- if (!Utils.isEmpty(startDate)) {
- params["start_date"] = startDate!;
- }
- if (!Utils.isEmpty(endDate)) {
- params["end_date"] = endDate!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiSignApplied,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = AttendanceEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<AttendanceEntity>(data: data);
- }
- return result.convert();
- }
- /// 用户上传考勤
- Future<HttpResult<CheckSuccessEntity>> submitCheckInOut(
- String? appliedId,
- ByteData? byteData, {
- bool isCheckIn = false,
- CancelToken? cancelToken,
- }) async {
- //Post请求
- Map<String, String> params = {};
- params['applied_id'] = appliedId ?? "";
- params['check_type'] = isCheckIn ? "1" : "2";
- Map<String, Uint8List> streams = {};
- if (byteData != null) {
- streams["capture"] = byteData.buffer.asUint8List();
- }
- final result = await httpProvider.requestNetResult(
- method: HttpMethod.POST,
- ApiConstants.apiSignInOut,
- params: params,
- pathStreams: streams,
- networkDebounce: true,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- final json = result.getDataJson();
- var data = CheckSuccessEntity.fromJson(json!);
- //重新赋值data
- return result.convert<CheckSuccessEntity>(data: data);
- }
- return result.convert<CheckSuccessEntity>();
- }
- /// 工作列表的筛选选项
- Future<HttpResult<JobListIndexEntity>> fetchJobListIndex({
- CancelToken? cancelToken,
- }) async {
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListIndex,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListIndexEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListIndexEntity>(data: data);
- }
- return result.convert();
- }
- /// 获取工作列表的主列表
- Future<HttpResult<JobListEntity>> fetchJobListTable(
- String? keyword,
- String? startDate,
- String? endDate,
- String? statusId,
- String? departmentId, {
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = curPage.toString();
- params["page_size"] = "20";
- if (!Utils.isEmpty(keyword)) {
- params["job_title"] = keyword!;
- }
- if (!Utils.isEmpty(startDate)) {
- params["start_time"] = startDate!;
- }
- if (!Utils.isEmpty(endDate)) {
- params["end_time"] = endDate!;
- }
- if (!Utils.isEmpty(statusId)) {
- params["status"] = statusId!;
- }
- if (!Utils.isEmpty(departmentId)) {
- params["co_department_id"] = departmentId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListTable,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListEntity>(data: data);
- }
- return result.convert();
- }
- /// 工作列表的详情
- Future<HttpResult<JobListDetailEntity>> fetchJobListDetail(
- String? jobId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['job_id'] = jobId ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListDetail,
- params: params,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListDetailEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListDetailEntity>(data: data);
- }
- return result.convert();
- }
- /// 工作中已申请的工作信息
- Future<HttpResult<JobListAppliedInfoEntity>> fetchJobAppliedInfo(
- String? jobId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params['job_id'] = jobId ?? "";
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedJobInfo,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListAppliedInfoEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListAppliedInfoEntity>(data: data);
- }
- return result.convert();
- }
- /// 工作中已申请的成员列表
- Future<HttpResult<JobListAppliedStaffListEntity>> fetchJobAppliedStaffs(
- String? jobId,
- String? staffName, {
- String? appliedId,
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = curPage.toString();
- params["page_size"] = "10";
- if (!Utils.isEmpty(jobId)) {
- params["job_id"] = jobId!;
- }
- if (!Utils.isEmpty(appliedId)) {
- params["applied_id"] = appliedId!;
- }
- if (!Utils.isEmpty(staffName)) {
- params["staff_name"] = staffName!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffList,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListAppliedStaffListEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListAppliedStaffListEntity>(data: data);
- }
- return result.convert();
- }
- /// 根据ID获取主列表的Item数据,用于刷新Item
- Future<HttpResult<JobListAppliedStaffListEntity>> fetchItemByAppliedIds(
- String? jobId,
- String? appliedIds, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = "1";
- params["page_size"] = "9999";
- if (!Utils.isEmpty(appliedIds)) {
- params["applied_ids"] = appliedIds!;
- }
- if (!Utils.isEmpty(jobId)) {
- params["job_id"] = jobId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffList,
- params: params,
- isShowLoadingDialog: true,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListAppliedStaffListEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListAppliedStaffListEntity>(data: data);
- }
- return result.convert();
- }
- /// 添加员工的全部员工数据列表
- Future<HttpResult<JobListAppliedStaffSearchEntity>> searchStaffList(
- String? jobId,
- String? keyword, {
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = curPage.toString();
- params["page_size"] = "10";
- if (!Utils.isEmpty(jobId)) {
- params["job_id"] = jobId!;
- }
- if (!Utils.isEmpty(keyword)) {
- params["keyword"] = keyword!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffSearch,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListAppliedStaffSearchEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListAppliedStaffSearchEntity>(data: data);
- }
- return result.convert();
- }
- /// 添加员工到工作
- Future<HttpResult<JobListAddStaffEntity>> addStaff2Job(
- String? jobId,
- String? staffIds, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(jobId)) {
- params["job_id"] = jobId!;
- }
- if (!Utils.isEmpty(staffIds)) {
- params["staff_ids"] = staffIds!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffAdd,
- isShowLoadingDialog: true,
- method: HttpMethod.POST,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListAddStaffEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListAddStaffEntity>(data: data);
- }
- return result.convert();
- }
- /// 批量修改员工的签到信息与状态
- Future<HttpResult> batchEditStaffCheckTime(
- String? jobId,
- String? appliedIds,
- String? startTime,
- String? endTime, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(startTime)) {
- params["start_time"] = startTime!;
- }
- if (!Utils.isEmpty(endTime)) {
- params["end_time"] = endTime!;
- }
- if (!Utils.isEmpty(appliedIds)) {
- params["applied_ids"] = appliedIds!;
- }
- if (!Utils.isEmpty(jobId)) {
- params["job_id"] = jobId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffBatchEdit,
- isShowLoadingDialog: true,
- method: HttpMethod.POST,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 获取单个员工的信息,准备修改
- Future<HttpResult<JobListAppliedEditEntity>> fetchAppliedEditView(
- String? appliedId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(appliedId)) {
- params["applied_id"] = appliedId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffEditIndex,
- isShowLoadingDialog: true,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListAppliedEditEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListAppliedEditEntity>(data: data);
- }
- return result.convert();
- }
- /// 单独修改单个员工的信息
- Future<HttpResult> editAppliedSingleStaffInfo(
- String? appliedId,
- JobListAppliedEditEntity entity, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(appliedId)) {
- params["applied_id"] = appliedId!;
- }
- if (!Utils.isEmpty(entity.startTime)) {
- params["start_time"] = entity.startTime!;
- }
- if (!Utils.isEmpty(entity.endTime)) {
- params["end_time"] = entity.endTime!;
- }
- if (!Utils.isEmpty(entity.securityIn)) {
- params["security_in"] = entity.securityIn!;
- }
- if (!Utils.isEmpty(entity.securityOut)) {
- params["security_out"] = entity.securityOut!;
- }
- if (!Utils.isEmpty(entity.workIn)) {
- params["work_in"] = entity.workIn!;
- }
- if (!Utils.isEmpty(entity.workOut)) {
- params["work_out"] = entity.workOut!;
- }
- if (entity.jobUnit == "hour") {
- if (!Utils.isEmpty(entity.adjustHours)) {
- params["adjust_hours"] = entity.adjustHours!;
- }
- } else {
- if (entity.totalRooms != 0) {
- params["total_rooms"] = entity.totalRooms.toString();
- }
- }
- if (entity.reasonType != 0) {
- params["co_reason_type"] = entity.reasonType.toString();
- }
- if (!Utils.isEmpty(entity.coReason)) {
- params["co_reason"] = entity.coReason!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffEditSubmit,
- isShowLoadingDialog: true,
- method: HttpMethod.POST,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 给员工评分的详情与选项
- Future<HttpResult<JobListRemarkViewEntity>> fetchAppliedStaffReviewView(
- String? appliedId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(appliedId)) {
- params["applied_id"] = appliedId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffReviewIndex,
- isShowLoadingDialog: true,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListRemarkViewEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListRemarkViewEntity>(data: data);
- }
- return result.convert();
- }
- /// 单独给单个员工评分的提交
- Future<HttpResult> remarkAppliedSingleStaffSubmit(
- String? appliedId,
- String? attitude_rate,
- String? grooming_rate,
- String? performance_rate,
- String? experience_rate,
- String? content, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(appliedId)) {
- params["applied_id"] = appliedId!;
- }
- if (!Utils.isEmpty(attitude_rate)) {
- params["attitude_rate"] = attitude_rate!;
- }
- if (!Utils.isEmpty(grooming_rate)) {
- params["grooming_rate"] = grooming_rate!;
- }
- if (!Utils.isEmpty(performance_rate)) {
- params["performance_rate"] = performance_rate!;
- }
- if (!Utils.isEmpty(experience_rate)) {
- params["experience_rate"] = experience_rate!;
- }
- if (!Utils.isEmpty(content)) {
- params["content"] = content!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffReviewSubmit,
- isShowLoadingDialog: true,
- method: HttpMethod.POST,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- /// 批量提交多个员工的考勤
- Future<HttpResult> submitBatchStaffApprove(
- String? appliedIds, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(appliedIds)) {
- params["applied_ids"] = appliedIds!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedApprove,
- isShowLoadingDialog: true,
- method: HttpMethod.POST,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- return result.convert();
- }
- return result.convert();
- }
- // 员工状态的工作流
- Future<HttpResult<JobListAppliedWorkFlowEntity>> fetchAppliedWorkFlow(
- String? appliedId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(appliedId)) {
- params["applied_id"] = appliedId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListAppliedStaffStateWorkflow,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = JobListAppliedWorkFlowEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<JobListAppliedWorkFlowEntity>(data: data);
- }
- return result.convert();
- }
- // 员工的信息
- Future<HttpResult<StaffDetailEntity>> fetchStaffDetail(
- String? memberId, {
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- if (!Utils.isEmpty(memberId)) {
- params["member_id"] = memberId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListStaffDetail,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = StaffDetailEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<StaffDetailEntity>(data: data);
- }
- return result.convert();
- }
- // 员工的历史申请记录
- Future<HttpResult<StaffLabourHistoryEntity>> fetchStaffLabourHistory(
- String? memberId,
- String? keyword, {
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = curPage.toString();
- params["page_size"] = "10";
- if (!Utils.isEmpty(memberId)) {
- params["member_id"] = memberId!;
- }
- if (!Utils.isEmpty(keyword)) {
- params["keyword"] = keyword!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListStaffLabourHistory,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = StaffLabourHistoryEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<StaffLabourHistoryEntity>(data: data);
- }
- return result.convert();
- }
- // 员工的历史评价记录
- Future<HttpResult<StaffRemarkHistoryEntity>> fetchStaffRemarkHistory(
- String? memberId, {
- required int curPage,
- CancelToken? cancelToken,
- }) async {
- //参数
- Map<String, String> params = {};
- params["cur_page"] = curPage.toString();
- params["page_size"] = "10";
- if (!Utils.isEmpty(memberId)) {
- params["member_id"] = memberId!;
- }
- final result = await httpProvider.requestNetResult(
- ApiConstants.apiJobListStaffRemarkHistory,
- params: params,
- cancelToken: cancelToken,
- );
- //根据返回的结果,封装原始数据为Bean/Entity对象
- if (result.isSuccess) {
- //重新赋值data或list
- final json = result.getDataJson();
- var data = StaffRemarkHistoryEntity.fromJson(json!);
- //重新赋值data或list
- return result.convert<StaffRemarkHistoryEntity>(data: data);
- }
- return result.convert();
- }
- }
|