소스 검색

财务报表与工作时长报表

liukai 1 주 전
부모
커밋
df7df12710

+ 3 - 2
packages/cpt_uk/lib/modules/report/finance_report/report_finance_controller.dart

@@ -1,4 +1,5 @@
 import 'package:domain/repository/other_repository.dart';
+import 'package:domain/repository/uk_report_repository.dart';
 import 'package:get/get.dart';
 import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
 import 'package:shared/utils/date_time_utils.dart';
@@ -8,7 +9,7 @@ import 'package:widgets/picker/date_picker_util.dart';
 import 'report_finance_state.dart';
 
 class ReportFinanceController extends GetxController with DioCancelableMixin {
-  final OtherRepository _otherRepository = Get.find();
+  final UKReportRepository _reportRepository = Get.find();
   final ReportFinanceState state = ReportFinanceState();
 
   //页面PlaceHolder的展示
@@ -30,7 +31,7 @@ class ReportFinanceController extends GetxController with DioCancelableMixin {
   void fetchReportData() async {
     changeLoadingState(LoadState.State_Loading);
 
-    var result = await _otherRepository.fetchReportFiance(
+    var result = await _reportRepository.fetchReportFiance(
       DateTimeUtils.formatDate(state.startDateTime, format: "yyyy-MM-dd"),
       DateTimeUtils.formatDate(state.endDateTime, format: "yyyy-MM-dd"),
       cancelToken: cancelToken,

+ 2 - 2
packages/cpt_uk/lib/modules/report/finance_report/report_finance_state.dart

@@ -2,8 +2,8 @@ import 'package:domain/entity/response/fiance_report_entity.dart';
 
 class ReportFinanceState {
 
-  DateTime? startDateTime;
-  DateTime? endDateTime;
+  DateTime? startDateTime = DateTime.now().subtract(const Duration(days: 7));
+  DateTime? endDateTime = DateTime.now();
 
   FianceReportEntity? entity;  //页面数据
 

+ 2 - 26
packages/cpt_uk/lib/modules/report/working_hours_report/widget/working_hours_filter.dart

@@ -1,13 +1,12 @@
 import 'dart:typed_data';
 import 'dart:ui';
 import 'package:cs_resources/generated/assets.dart';
-import 'package:domain/entity/response/labour_request_index_entity.dart';
+import 'package:domain/entity/response/u_k_security_attendance_option_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
 import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
 import 'package:get/get.dart';
-import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:shared/utils/date_time_utils.dart';
 import 'package:shared/utils/screen_util.dart';
 import 'package:widgets/ext/ex_widget.dart';
@@ -24,7 +23,7 @@ import 'package:widgets/widget_export.dart';
  */
 class WorkingHoursFilter extends StatefulWidget {
   void Function(DateTime? selectedStartDate, DateTime? selectedEndDate, String? selectedDepartmentId)? onFilterAction;
-  LabourRequestIndexEntity optionResult;
+  UKSecurityAttendanceOptionEntity optionResult;
   DateTime? selectedStartDate;
   DateTime? selectedEndDate;
   String? selectedDepartmentId;
@@ -292,27 +291,4 @@ class _LabourReviewFilterState extends State<WorkingHoursFilter> {
     );
   }
 
-  /// 筛选状态
-  void pickerStatus() {
-    int selectedStatusIndex;
-    if (selectedStatusId == null) {
-      selectedStatusIndex = 0;
-    } else {
-      selectedStatusIndex = widget.optionResult.statusList!.indexWhere((department) => department.value.toString() == selectedStatusId);
-    }
-
-    if (selectedStatusIndex < 0) {
-      selectedStatusIndex = 0;
-    }
-
-    OptionPickerUtil.showCupertinoOptionPicker(
-      items: widget.optionResult.statusList!.map((e) => e.txt!).toList(growable: false),
-      initialSelectIndex: selectedStatusIndex,
-      onPickerChanged: (_, index) {
-        setState(() {
-          selectedStatusId = widget.optionResult.statusList![index].value!.toString();
-        });
-      },
-    );
-  }
 }

+ 17 - 18
packages/cpt_uk/lib/modules/report/working_hours_report/working_hours_report_controller.dart

@@ -1,21 +1,20 @@
-import 'package:cpt_uk/modules/report/working_hours_report/widget/working_hours_filter.dart';
-import 'package:domain/entity/response/labour_request_index_entity.dart';
-import 'package:domain/entity/response/labour_review_list_entity.dart';
-import 'package:domain/repository/labour_repository.dart';
+
+import 'package:domain/entity/response/u_k_report_working_hours_entity.dart';
+import 'package:domain/entity/response/u_k_security_attendance_option_entity.dart';
+import 'package:domain/repository/uk_report_repository.dart';
 import 'package:get/get.dart';
 import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
-import 'package:plugin_platform/engine/notify/notify_engine.dart';
-import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
 import 'package:plugin_platform/http/http_result.dart';
 import 'package:shared/utils/date_time_utils.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
+import 'widget/working_hours_filter.dart';
 import 'working_hours_report_state.dart';
 
 class WorkingHoursReportController extends GetxController with DioCancelableMixin {
-  final LabourRepository _labourRepository = Get.find();
+  final UKReportRepository _reportRepository = Get.find();
   final WorkingHoursReportState state = WorkingHoursReportState();
 
   var _curPage = 1;
@@ -64,25 +63,24 @@ class WorkingHoursReportController extends GetxController with DioCancelableMixi
 
     // 并发执行两个请求,拿到选项数据与列表数据
     var futures = [
-      _labourRepository.fetchLabourReviewList(
-        "",
-        DateTimeUtils.formatDate(state.selectedStartDate, format: "yyyy-MM-dd"),
-        DateTimeUtils.formatDate(state.selectedEndDate, format: "yyyy-MM-dd"),
-        state.selectedDepartmentId,
+      _reportRepository.fetchReportWorkingHoursList(
+        startDate: DateTimeUtils.formatDate(state.selectedStartDate, format: "yyyy-MM-dd"),
+        endDate: DateTimeUtils.formatDate(state.selectedEndDate, format: "yyyy-MM-dd"),
+        departmentId: state.selectedDepartmentId,
         curPage: _curPage,
         cancelToken: cancelToken,
       ),
       state.indexOptions == null
-          ? _labourRepository.fetchLabourReviewIndex(
-              cancelToken: cancelToken,
-            )
+          ? _reportRepository.fetchReportOptions(
+        cancelToken: cancelToken,
+      )
           : Future(() => HttpResult(isSuccess: true).convert(data: state.indexOptions!)),
     ];
 
     //拿到结果
     var results = await Future.wait(futures);
-    var listResult = results[0] as HttpResult<LabourReviewListEntity>;
-    var optionResult = results[1] as HttpResult<LabourRequestIndexEntity>;
+    var listResult = results[0] as HttpResult<UKReportWorkingHoursEntity>;
+    var optionResult = results[1] as HttpResult<UKSecurityAttendanceOptionEntity>;
 
     //选项数据
     if (state.indexOptions == null && optionResult.isSuccess) {
@@ -102,7 +100,7 @@ class WorkingHoursReportController extends GetxController with DioCancelableMixi
   }
 
   // 处理数据与展示的逻辑
-  void handleList(List<LabourReviewListRows>? list) {
+  void handleList(List<UKReportWorkingHoursRows>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_curPage == 1) {
@@ -169,4 +167,5 @@ class WorkingHoursReportController extends GetxController with DioCancelableMixi
       );
     }
   }
+
 }

+ 7 - 6
packages/cpt_uk/lib/modules/report/working_hours_report/working_hours_report_item.dart

@@ -1,5 +1,6 @@
 import 'package:cs_resources/constants/color_constants.dart';
 import 'package:domain/entity/response/labour_review_list_entity.dart';
+import 'package:domain/entity/response/u_k_report_working_hours_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
@@ -13,7 +14,7 @@ import 'package:widgets/my_text_view.dart';
  */
 class WorkingHoursReportItem extends StatelessWidget {
   final int index;
-  final LabourReviewListRows item;
+  final UKReportWorkingHoursRows item;
 
   WorkingHoursReportItem({
     required this.index,
@@ -47,7 +48,7 @@ class WorkingHoursReportItem extends StatelessWidget {
 
               //部门
               MyTextView(
-                item.jobTime ?? "-",
+                item.jobDate ?? "-",
                 marginLeft: 5,
                 isFontRegular: true,
                 textColor: Colors.white,
@@ -116,7 +117,7 @@ class WorkingHoursReportItem extends StatelessWidget {
 
               //日期时间
               MyTextView(
-                item.jobTime ?? "-",
+                item.startTime ?? "-",
                 marginLeft: 5,
                 isFontRegular: true,
                 textColor: Colors.white,
@@ -139,7 +140,7 @@ class WorkingHoursReportItem extends StatelessWidget {
 
               //日期时间
               MyTextView(
-                item.jobTime ?? "-",
+                item.endTime ?? "-",
                 marginLeft: 5,
                 isFontRegular: true,
                 textColor: Colors.white,
@@ -162,7 +163,7 @@ class WorkingHoursReportItem extends StatelessWidget {
 
               //发布状态
               MyTextView(
-                item.needNum ?? "-",
+                item.completeNum ?? "-",
                 marginLeft: 5,
                 isFontRegular: true,
                 textColor: Colors.white,
@@ -185,7 +186,7 @@ class WorkingHoursReportItem extends StatelessWidget {
 
               //发布状态
               MyTextView(
-                "8",
+                item.workingHours ?? "-",
                 marginLeft: 5,
                 isFontRegular: true,
                 textColor: Colors.white,

+ 5 - 4
packages/cpt_uk/lib/modules/report/working_hours_report/working_hours_report_state.dart

@@ -1,5 +1,6 @@
-import 'package:domain/entity/response/labour_request_index_entity.dart';
-import 'package:domain/entity/response/labour_review_list_entity.dart';
+
+import 'package:domain/entity/response/u_k_report_working_hours_entity.dart';
+import 'package:domain/entity/response/u_k_security_attendance_option_entity.dart';
 
 class WorkingHoursReportState {
   DateTime? selectedStartDate;
@@ -7,6 +8,6 @@ class WorkingHoursReportState {
   String? selectedDepartmentId;
 
   //页面的列表数据
-  List<LabourReviewListRows> datas = [];
-  LabourRequestIndexEntity? indexOptions;
+  List<UKReportWorkingHoursRows> datas = [];
+  UKSecurityAttendanceOptionEntity? indexOptions;
 }

+ 6 - 0
packages/cs_domain/lib/constants/api_constants.dart

@@ -304,6 +304,12 @@ class ApiConstants {
   //UK的电子考勤报表
   static const apiReportAttendanceUK = "/index.php/api/v1/hotel/report/attendance";
 
+  //UK的财务报表
+  static const apiReportFianceUK = "/index.php/api/v1/hotel/report/finale";
+
+  //UK的工作时长报表
+  static const apiReportWorkingHoursUK = "/index.php/api/v1/hotel/report/working-hours";
+
   // =========================== 报表与其他 ↓=========================================
 
   // 设备列表

+ 52 - 0
packages/cs_domain/lib/entity/response/u_k_report_working_hours_entity.dart

@@ -0,0 +1,52 @@
+import 'package:domain/generated/json/base/json_field.dart';
+import 'package:domain/generated/json/u_k_report_working_hours_entity.g.dart';
+import 'dart:convert';
+export 'package:domain/generated/json/u_k_report_working_hours_entity.g.dart';
+
+@JsonSerializable()
+class UKReportWorkingHoursEntity {
+	int total = 0;
+	List<UKReportWorkingHoursRows> rows = [];
+
+	UKReportWorkingHoursEntity();
+
+	factory UKReportWorkingHoursEntity.fromJson(Map<String, dynamic> json) => $UKReportWorkingHoursEntityFromJson(json);
+
+	Map<String, dynamic> toJson() => $UKReportWorkingHoursEntityToJson(this);
+
+	@override
+	String toString() {
+		return jsonEncode(this);
+	}
+}
+
+@JsonSerializable()
+class UKReportWorkingHoursRows {
+	@JSONField(name: "job_id")
+	String? jobId;
+	@JSONField(name: "job_date")
+	String? jobDate;
+	@JSONField(name: "department_name")
+	String? departmentName;
+	@JSONField(name: "job_title")
+	String? jobTitle;
+	@JSONField(name: "start_time")
+	String? startTime;
+	@JSONField(name: "end_time")
+	String? endTime;
+	@JSONField(name: "complete_num")
+	String? completeNum;
+	@JSONField(name: "working_hours")
+	String? workingHours;
+
+	UKReportWorkingHoursRows();
+
+	factory UKReportWorkingHoursRows.fromJson(Map<String, dynamic> json) => $UKReportWorkingHoursRowsFromJson(json);
+
+	Map<String, dynamic> toJson() => $UKReportWorkingHoursRowsToJson(this);
+
+	@override
+	String toString() {
+		return jsonEncode(this);
+	}
+}

+ 9 - 0
packages/cs_domain/lib/generated/json/base/json_convert_content.dart

@@ -81,6 +81,7 @@ import 'package:domain/entity/response/staff_review_history_s_g_entity.dart';
 import 'package:domain/entity/response/u_k_attendance_entity.dart';
 import 'package:domain/entity/response/u_k_report_attendance_entity.dart';
 import 'package:domain/entity/response/u_k_report_labour_entity.dart';
+import 'package:domain/entity/response/u_k_report_working_hours_entity.dart';
 import 'package:domain/entity/response/u_k_security_attendance_entity.dart';
 import 'package:domain/entity/response/u_k_security_attendance_option_entity.dart';
 import 'package:domain/entity/server_time.dart';
@@ -699,6 +700,12 @@ class JsonConvert {
     if (<UKReportLabourRows>[] is M) {
       return data.map<UKReportLabourRows>((Map<String, dynamic> e) => UKReportLabourRows.fromJson(e)).toList() as M;
     }
+    if (<UKReportWorkingHoursEntity>[] is M) {
+      return data.map<UKReportWorkingHoursEntity>((Map<String, dynamic> e) => UKReportWorkingHoursEntity.fromJson(e)).toList() as M;
+    }
+    if (<UKReportWorkingHoursRows>[] is M) {
+      return data.map<UKReportWorkingHoursRows>((Map<String, dynamic> e) => UKReportWorkingHoursRows.fromJson(e)).toList() as M;
+    }
     if (<UKSecurityAttendanceEntity>[] is M) {
       return data.map<UKSecurityAttendanceEntity>((Map<String, dynamic> e) => UKSecurityAttendanceEntity.fromJson(e)).toList() as M;
     }
@@ -898,6 +905,8 @@ class JsonConvertClassCollection {
     (UKReportAttendanceRows).toString(): UKReportAttendanceRows.fromJson,
     (UKReportLabourEntity).toString(): UKReportLabourEntity.fromJson,
     (UKReportLabourRows).toString(): UKReportLabourRows.fromJson,
+    (UKReportWorkingHoursEntity).toString(): UKReportWorkingHoursEntity.fromJson,
+    (UKReportWorkingHoursRows).toString(): UKReportWorkingHoursRows.fromJson,
     (UKSecurityAttendanceEntity).toString(): UKSecurityAttendanceEntity.fromJson,
     (UKSecurityAttendanceRows).toString(): UKSecurityAttendanceRows.fromJson,
     (UKSecurityInOut).toString(): UKSecurityInOut.fromJson,

+ 107 - 0
packages/cs_domain/lib/generated/json/u_k_report_working_hours_entity.g.dart

@@ -0,0 +1,107 @@
+import 'package:domain/generated/json/base/json_convert_content.dart';
+import 'package:domain/entity/response/u_k_report_working_hours_entity.dart';
+
+UKReportWorkingHoursEntity $UKReportWorkingHoursEntityFromJson(Map<String, dynamic> json) {
+  final UKReportWorkingHoursEntity uKReportWorkingHoursEntity = UKReportWorkingHoursEntity();
+  final int? total = jsonConvert.convert<int>(json['total']);
+  if (total != null) {
+    uKReportWorkingHoursEntity.total = total;
+  }
+  final List<UKReportWorkingHoursRows>? rows = (json['rows'] as List<dynamic>?)?.map(
+          (e) => jsonConvert.convert<UKReportWorkingHoursRows>(e) as UKReportWorkingHoursRows).toList();
+  if (rows != null) {
+    uKReportWorkingHoursEntity.rows = rows;
+  }
+  return uKReportWorkingHoursEntity;
+}
+
+Map<String, dynamic> $UKReportWorkingHoursEntityToJson(UKReportWorkingHoursEntity entity) {
+  final Map<String, dynamic> data = <String, dynamic>{};
+  data['total'] = entity.total;
+  data['rows'] = entity.rows.map((v) => v.toJson()).toList();
+  return data;
+}
+
+extension UKReportWorkingHoursEntityExtension on UKReportWorkingHoursEntity {
+  UKReportWorkingHoursEntity copyWith({
+    int? total,
+    List<UKReportWorkingHoursRows>? rows,
+  }) {
+    return UKReportWorkingHoursEntity()
+      ..total = total ?? this.total
+      ..rows = rows ?? this.rows;
+  }
+}
+
+UKReportWorkingHoursRows $UKReportWorkingHoursRowsFromJson(Map<String, dynamic> json) {
+  final UKReportWorkingHoursRows uKReportWorkingHoursRows = UKReportWorkingHoursRows();
+  final String? jobId = jsonConvert.convert<String>(json['job_id']);
+  if (jobId != null) {
+    uKReportWorkingHoursRows.jobId = jobId;
+  }
+  final String? jobDate = jsonConvert.convert<String>(json['job_date']);
+  if (jobDate != null) {
+    uKReportWorkingHoursRows.jobDate = jobDate;
+  }
+  final String? departmentName = jsonConvert.convert<String>(json['department_name']);
+  if (departmentName != null) {
+    uKReportWorkingHoursRows.departmentName = departmentName;
+  }
+  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
+  if (jobTitle != null) {
+    uKReportWorkingHoursRows.jobTitle = jobTitle;
+  }
+  final String? startTime = jsonConvert.convert<String>(json['start_time']);
+  if (startTime != null) {
+    uKReportWorkingHoursRows.startTime = startTime;
+  }
+  final String? endTime = jsonConvert.convert<String>(json['end_time']);
+  if (endTime != null) {
+    uKReportWorkingHoursRows.endTime = endTime;
+  }
+  final String? completeNum = jsonConvert.convert<String>(json['complete_num']);
+  if (completeNum != null) {
+    uKReportWorkingHoursRows.completeNum = completeNum;
+  }
+  final String? workingHours = jsonConvert.convert<String>(json['working_hours']);
+  if (workingHours != null) {
+    uKReportWorkingHoursRows.workingHours = workingHours;
+  }
+  return uKReportWorkingHoursRows;
+}
+
+Map<String, dynamic> $UKReportWorkingHoursRowsToJson(UKReportWorkingHoursRows entity) {
+  final Map<String, dynamic> data = <String, dynamic>{};
+  data['job_id'] = entity.jobId;
+  data['job_date'] = entity.jobDate;
+  data['department_name'] = entity.departmentName;
+  data['job_title'] = entity.jobTitle;
+  data['start_time'] = entity.startTime;
+  data['end_time'] = entity.endTime;
+  data['complete_num'] = entity.completeNum;
+  data['working_hours'] = entity.workingHours;
+  return data;
+}
+
+extension UKReportWorkingHoursRowsExtension on UKReportWorkingHoursRows {
+  UKReportWorkingHoursRows copyWith({
+    String? jobId,
+    String? jobDate,
+    String? departmentName,
+    String? jobTitle,
+    String? startTime,
+    String? endTime,
+    String? completeNum,
+    String? workingHours,
+  }) {
+    return UKReportWorkingHoursRows()
+      ..jobId = jobId ?? this.jobId
+      ..jobDate = jobDate ?? this.jobDate
+      ..departmentName = departmentName ?? this.departmentName
+      ..jobTitle = jobTitle ?? this.jobTitle
+      ..startTime = startTime ?? this.startTime
+      ..endTime = endTime ?? this.endTime
+      ..completeNum = completeNum ?? this.completeNum
+      ..workingHours = workingHours ?? this.workingHours;
+  }
+}

+ 71 - 2
packages/cs_domain/lib/repository/uk_report_repository.dart

@@ -1,4 +1,6 @@
+import 'package:domain/entity/response/fiance_report_entity.dart';
 import 'package:domain/entity/response/u_k_report_attendance_entity.dart';
+import 'package:domain/entity/response/u_k_report_working_hours_entity.dart';
 import 'package:get/get.dart';
 import 'package:plugin_platform/http/http_provider.dart';
 import 'package:plugin_platform/http/http_result.dart';
@@ -15,7 +17,6 @@ class UKReportRepository extends GetxService {
 
   UKReportRepository({required this.httpProvider});
 
-
   /// 获取报表的筛选选项
   Future<HttpResult<UKSecurityAttendanceOptionEntity>> fetchReportOptions({
     CancelToken? cancelToken,
@@ -116,5 +117,73 @@ class UKReportRepository extends GetxService {
     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.apiReportFianceUK,
+      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<UKReportWorkingHoursEntity>> fetchReportWorkingHoursList({
+    String? startDate,
+    String? endDate,
+    String? departmentId,
+    int curPage = 1,
+    int pageSize = 10,
+    CancelToken? cancelToken,
+  }) async {
+    Map<String, String> params = {};
+    params["cur_page"] = curPage.toString();
+    params["page_size"] = pageSize.toString();
+
+    if (!Utils.isEmpty(departmentId)) {
+      params["co_department_id"] = departmentId!;
+    }
+    if (!Utils.isEmpty(startDate)) {
+      params["start_date"] = startDate!;
+    }
+    if (!Utils.isEmpty(endDate)) {
+      params["end_date"] = endDate!;
+    }
+
+    final result = await httpProvider.requestNetResult(
+      ApiConstants.apiReportWorkingHoursUK,
+      params: params,
+      cancelToken: cancelToken,
+    );
+
+    if (result.isSuccess) {
+      final json = result.getDataJson();
+      var data = UKReportWorkingHoursEntity.fromJson(json!);
+      return result.convert<UKReportWorkingHoursEntity>(data: data);
+    }
+    return result.convert();
+  }
 
-}
+}