2023-09-09 18:33:37 +08:00
|
|
|
|
2024-04-02 17:30:44 +08:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
2023-09-15 16:04:11 +08:00
|
|
|
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListDay_entity.dart';
|
2024-06-07 10:53:24 +08:00
|
|
|
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart';
|
|
|
|
|
import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
|
2023-09-09 18:33:37 +08:00
|
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
2024-06-07 10:53:24 +08:00
|
|
|
|
2023-09-09 18:33:37 +08:00
|
|
|
import '../../../../network/api_repository.dart';
|
2024-04-02 17:30:44 +08:00
|
|
|
import '../../../../tools/eventBusEventManage.dart';
|
2023-10-17 15:49:09 +08:00
|
|
|
import '../../../../tools/storage.dart';
|
2024-06-07 10:53:24 +08:00
|
|
|
|
2023-09-09 18:33:37 +08:00
|
|
|
import 'checkingInList_state.dart';
|
|
|
|
|
|
|
|
|
|
class CheckingInListLogic extends BaseGetXController{
|
|
|
|
|
CheckingInListState state = CheckingInListState();
|
|
|
|
|
|
|
|
|
|
// 开启考勤获取是否有公司
|
2024-06-07 10:53:24 +08:00
|
|
|
Future<void> openCheckingInData() async{
|
|
|
|
|
final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData(
|
2023-09-09 18:33:37 +08:00
|
|
|
lockId:state.getKeyInfosData.value.lockId.toString(),
|
|
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
state.companyId.value = entity.data!.companyId.toString();
|
2023-09-15 16:04:11 +08:00
|
|
|
getCheckInListEarlyArrivalWithDateData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void loadDataByType(){
|
2024-06-07 10:53:24 +08:00
|
|
|
if(state.isDay.value == true && (state.listType.value == '1')){
|
2023-09-15 16:04:11 +08:00
|
|
|
// 早到日榜
|
|
|
|
|
getCheckInListEarlyArrivalWithDateData();
|
2024-06-07 10:53:24 +08:00
|
|
|
}else if(state.isDay.value == false && (state.listType.value == '1')){
|
2023-09-15 16:04:11 +08:00
|
|
|
// 早到月榜
|
|
|
|
|
getCheckInListEarlyArrivalWithMonthData();
|
2024-06-07 10:53:24 +08:00
|
|
|
}else if(state.isDay.value == true && (state.listType.value == '2')){
|
2023-09-15 16:04:11 +08:00
|
|
|
// 迟到日榜
|
|
|
|
|
getCheckInListLateTimesWithDateData();
|
2024-06-07 10:53:24 +08:00
|
|
|
}else if(state.isDay.value == false && (state.listType.value == '2')){
|
2023-09-15 16:04:11 +08:00
|
|
|
// 迟到月榜
|
|
|
|
|
getCheckInListLateTimesWithMonthData();
|
|
|
|
|
}else {
|
|
|
|
|
// 勤奋榜
|
|
|
|
|
getCheckInListHardworkingData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取考勤信息列表--早到榜(按日期查询)
|
2024-06-07 10:53:24 +08:00
|
|
|
Future<void> getCheckInListEarlyArrivalWithDateData() async{
|
|
|
|
|
final CheckingInListDayEntity entity = await ApiRepository.to.getCheckInListEarlyArrivalWithDateData(
|
2023-09-15 16:04:11 +08:00
|
|
|
companyId: state.companyId.value,
|
|
|
|
|
attendanceDate:state.checkListDateTimestamp.value.toString(),
|
|
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
state.lateTimes.value = entity.data!.lateTimes.toString();
|
|
|
|
|
state.earlyTimes.value = entity.data!.earlyTimes.toString();
|
|
|
|
|
state.noPunchTimes.value = entity.data!.noPunchTimes.toString();
|
|
|
|
|
state.checkingInDayListData.value = entity.data!.attendanceRecordList!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取考勤信息列表--早到榜(按月榜查询)
|
2024-06-07 10:53:24 +08:00
|
|
|
Future<void> getCheckInListEarlyArrivalWithMonthData() async{
|
|
|
|
|
final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListEarlyArrivalWithMonthData(
|
2023-09-15 16:04:11 +08:00
|
|
|
companyId: state.companyId.value,
|
|
|
|
|
attendanceDate:state.checkListDateTimestamp.value.toString(),
|
|
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
state.checkingInMonthListData.value = entity.data!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取考勤信息列表--迟到榜(按日期查询)
|
2024-06-07 10:53:24 +08:00
|
|
|
Future<void> getCheckInListLateTimesWithDateData() async{
|
|
|
|
|
final CheckingInListDayEntity entity = await ApiRepository.to.getCheckInListLateTimesWithDateData(
|
2023-09-15 16:04:11 +08:00
|
|
|
companyId: state.companyId.value,
|
|
|
|
|
attendanceDate:state.checkListDateTimestamp.value.toString(),
|
|
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
state.lateTimes.value = entity.data!.lateTimes.toString();
|
|
|
|
|
state.earlyTimes.value = entity.data!.earlyTimes.toString();
|
|
|
|
|
state.noPunchTimes.value = entity.data!.noPunchTimes.toString();
|
|
|
|
|
state.checkingInDayListData.value = entity.data!.attendanceRecordList!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取考勤信息列表--迟到榜(按月榜查询)
|
2024-06-07 10:53:24 +08:00
|
|
|
Future<void> getCheckInListLateTimesWithMonthData() async{
|
|
|
|
|
final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListLateTimesWithMonthData(
|
2023-09-15 16:04:11 +08:00
|
|
|
companyId: state.companyId.value,
|
|
|
|
|
attendanceDate:state.checkListDateTimestamp.value.toString(),
|
|
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
state.checkingInMonthListData.value = entity.data!;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取考勤信息列表--勤奋榜(按月榜查询)
|
2024-06-07 10:53:24 +08:00
|
|
|
Future<void> getCheckInListHardworkingData() async{
|
|
|
|
|
final CheckingInListMonthEntity entity = await ApiRepository.to.getCheckInListHardworkingData(
|
2023-09-15 16:04:11 +08:00
|
|
|
companyId: state.companyId.value,
|
|
|
|
|
attendanceDate:state.checkListDateTimestamp.value.toString(),
|
2024-06-07 10:53:24 +08:00
|
|
|
type: state.isDay.value == true ? '1' : '2',
|
2023-09-15 16:04:11 +08:00
|
|
|
);
|
|
|
|
|
if(entity.errorCode!.codeIsSuccessful){
|
|
|
|
|
state.checkingInMonthListData.value = entity.data!;
|
2023-09-09 18:33:37 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-02 17:30:44 +08:00
|
|
|
late StreamSubscription _teamEvent;
|
|
|
|
|
void _initLoadDataAction() {
|
2024-06-07 10:53:24 +08:00
|
|
|
_teamEvent = eventBus.on<RefreshCheckInListEvent>().listen((RefreshCheckInListEvent event) {
|
2024-04-02 17:30:44 +08:00
|
|
|
loadDataByType();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-09 18:33:37 +08:00
|
|
|
@override
|
2023-10-17 15:49:09 +08:00
|
|
|
Future<void> onReady() async {
|
2023-09-09 18:33:37 +08:00
|
|
|
super.onReady();
|
|
|
|
|
|
2023-10-17 15:49:09 +08:00
|
|
|
// 获取是否是演示模式 演示模式不获取接口
|
2024-06-07 10:53:24 +08:00
|
|
|
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
2023-10-17 15:49:09 +08:00
|
|
|
if(isDemoMode == false){
|
2024-04-02 17:30:44 +08:00
|
|
|
_initLoadDataAction();
|
|
|
|
|
|
2023-10-17 15:49:09 +08:00
|
|
|
openCheckingInData();
|
|
|
|
|
}
|
2023-09-09 18:33:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void onClose() {
|
2024-04-02 17:30:44 +08:00
|
|
|
super.onClose();
|
2023-09-09 18:33:37 +08:00
|
|
|
|
2024-04-02 17:30:44 +08:00
|
|
|
_teamEvent.cancel();
|
2023-09-09 18:33:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|