timer and working hours issue fixes

design_3.0_latest
WaseemAbbasi22 9 months ago
parent 028f447959
commit ce1044f201

@ -62,7 +62,7 @@ class AllRequestsProvider extends ChangeNotifier {
// AllRequestsAndCount? get completedRequests => _completedRequests;
AllRequestsAndCount? get requestDetailList => _requestDetailList;
RecurrentWoData? _recurrentWoData;
RecurrentWoData? _recurrentWoData=RecurrentWoData();
RecurrentWoData? get recurrentWoData => _recurrentWoData;
@ -198,7 +198,6 @@ class AllRequestsProvider extends ChangeNotifier {
Response response;
try {
response = await ApiManager.instance.get(URLs.getRecurrentPlanByIdUrl + "?planRecurrentTaskId=$id");
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
recurrentWoData = RecurrentWoData.fromJson(json.decode(response.body)["data"]);
@ -220,7 +219,6 @@ class AllRequestsProvider extends ChangeNotifier {
Response response;
try {
response = await ApiManager.instance.post(URLs.updateRecurrentPlanUrl, body: recurrentWoData!.toJson(status: status));
print('response i got back is ${response.body}');
stateCode = response.statusCode;
isLoading = false;
notifyListeners();

@ -530,10 +530,10 @@
"createdDate": "تاريخ الإنشاء",
"employeeId": "رقم الموظف",
"extensionNo": "رقم التمديد",
"recurrentWo": "أمر العمل المتكرر"
"checkIn": "تسجيل الدخول",
"pmWo": "أمر العمل الوقائي",
"recurrentWo": "أمر العمل المتكرر",
"taskNo": "رقم المهمة",
"assignEngineer": "تعيين مهندس",
"scheduledDate": "التاريخ المجدول",

@ -537,10 +537,7 @@
"assignEngineer": "Assign Engineer",
"scheduledDate": "Scheduled Date",
"complete": "Complete",
"recurrentWo": "Recurrent WO"
"checkIn": "Check in",
"createdDate": "Created Date",
"employeeId": "Employee ID",
"extensionNo": "Extension No",
"recurrentWo": "Recurrent WO"
"extensionNo": "Extension No"
}

@ -49,7 +49,7 @@ class RecurrentWoData {
List<PlanRecurrentMedicalTaskRooms>? planRecurrentMedicalTaskRooms;
List<PlanRecurrentTaskTimers>? planRecurrentTaskTimers;
TimerModel? recurrentWoTimerModel = TimerModel();
double? totalWorkingHours=0.0;
double? totalWorkingHours = 0.0;
RecurrentWoData(
{this.id,
@ -82,12 +82,14 @@ class RecurrentWoData {
planRecurrentMedicalTaskRooms!.add(PlanRecurrentMedicalTaskRooms.fromJson(v));
});
}
if (json['planRecurrentTaskTimers'] != null) {
planRecurrentTaskTimers = <PlanRecurrentTaskTimers>[];
json['planRecurrentTaskTimers'].forEach((v) {
planRecurrentTaskTimers?.add(PlanRecurrentTaskTimers.fromJson(v));
});
totalWorkingHours = json['planRecurrentTaskTimers'].fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endTime!).difference(DateTime.parse(item.startTime!)).inSeconds) ?? 0;
//TODO need to test this @waseem..
totalWorkingHours = json['planRecurrentTaskTimers'].fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item['endDateTime']).difference(DateTime.parse(item['startDateTime'])).inSeconds) ?? 0;
}
}
@ -110,8 +112,7 @@ class RecurrentWoData {
}
if (taskRoomTabAttributesJson.isNotEmpty) {
data['attributes'] = taskRoomTabAttributesJson;
}
else{
} else {
data['attributes'] = [];
}
@ -182,7 +183,7 @@ class Site {
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = {};
data['id'] =id;
data['id'] = id;
data['siteName'] = siteName;
return data;
}
@ -253,7 +254,7 @@ class PlanRecurrentMedicalTaskRoomTabs {
if (json['planRecurrentMedicalTaskRoomTabAttributes'] != null) {
planRecurrentMedicalTaskRoomTabAttributes = <PlanRecurrentMedicalTaskRoomTabAttributes>[];
json['planRecurrentMedicalTaskRoomTabAttributes'].forEach((v) {
planRecurrentMedicalTaskRoomTabAttributes!.add( PlanRecurrentMedicalTaskRoomTabAttributes.fromJson(v));
planRecurrentMedicalTaskRoomTabAttributes!.add(PlanRecurrentMedicalTaskRoomTabAttributes.fromJson(v));
});
}
}
@ -286,7 +287,7 @@ class PlanRecurrentMedicalTaskRoomTabAttributes {
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['attributeValue'] =attributeValue!=null? attributeValue.toString():attributeValue;
data['attributeValue'] = attributeValue != null ? attributeValue.toString() : attributeValue;
return data;
}
}
@ -325,17 +326,17 @@ class PlanRecurrentTaskTimers {
PlanRecurrentTaskTimers.fromJson(Map<String, dynamic> json) {
id = json['id'];
startTime = json['startTime'];
endTime = json['endTime'];
workingHours = json['workingHours'];
startTime = json['startDateTime'];
endTime = json['endDateTime'];
workingHours = json['workingHour'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['startTime'] = startTime;
data['endTime'] = endTime;
data['workingHours'] = workingHours;
data['startDateTime'] = startTime;
data['endDateTime'] = endTime;
data['workingHour'] = workingHours;
return data;
}
}

@ -49,8 +49,8 @@ class RecurrentWoItemView extends StatelessWidget {
8.height,
(requestDetails?.nameOfType ?? context.translation.ppmRequest).heading5(context),
8.height,
'${context.translation.assetNumber}: ${requestDetails!.assetNo}'.bodyText(context),
'${context.translation.assetSN}: ${requestDetails!.assetSN}'.bodyText(context),
'${context.translation.taskNo}: ${requestDetails!.id}'.bodyText(context),
'${context.translation.site}: ${requestDetails!.site}'.bodyText(context),
// '${context.translation.code}: ${request.code}'.bodyText(context),
'${context.translation.requestNo}: ${requestDetails!.requestNo}'.bodyText(context),
16.height,

@ -1,184 +0,0 @@
class DummyData {
static List<Map<String, dynamic>> roomData = [
{
"name": "Room 1",
"cards": [
{
"title": "General Inspection",
"info": [
{
"label": "Room Temperature (15-35 C)",
"value": true
},
{
"label": "Room Humidity <35%",
"value": true
},
{
"label": "Valve value",
"value": false
},
{
"label": "Alarm Check",
"value": true
},
{
"label": "Overall Result",
"value": true
}
]
},
{
"title": "Manifold",
"info": [
{
"label": "Room Temperature (15-35 C)",
"value": true
},
{
"label": "Room Humidity <35%",
"value": true
},
{
"label": "Valve value",
"value": false
},
{
"label": "Alarm Check",
"value": true
}
]
}
]
},
{
"name": "Room 2",
"cards": [
{
"title": "General Inspection",
"info": [
{
"label": "Room Temperature (15-35 C)",
"value": true
},
{
"label": "Room Humidity <35%",
"value": true
},
{
"label": "Valve value",
"value": true
},
{
"label": "Alarm Check",
"value": true
},
{
"label": "Overall Result",
"value": true
}
]
}
]
},
{
"name": "Room 3",
"cards": [
{
"title": "General Inspection",
"info": [
{
"label": "Room Temperature (15-35 C)",
"value": false
},
{
"label": "Room Humidity <35%",
"value": false
},
{
"label": "Valve value",
"value": true
},
{
"label": "Alarm Check",
"value": true
},
{
"label": "Overall Result",
"value": false
}
]
}
]
},
{
"name": "Room 4",
"cards": [
{
"title": "General Inspection",
"info": [
{
"label": "Room Temperature (15-35 C)",
"value": false
},
{
"label": "Room Humidity <35%",
"value": false
},
{
"label": "Valve value",
"value": true
},
{
"label": "Alarm Check",
"value": true
},
{
"label": "Overall Result",
"value": false
}
]
},
{
"title": "General Inspection",
"info": [
{
"label": "Room Temperature (15-35 C)",
"value": false
},
{
"label": "Room Humidity <35%",
"value": false
},
{
"label": "Valve value",
"value": true
},
{
"label": "Alarm Check",
"value": true
},
]
},
{
"title": "General Inspection",
"info": [
{
"label": "Room Temperature (15-35 C)",
"value": false
},
{
"label": "Room Humidity <35%",
"value": false
},
{
"label": "Valve value",
"value": true
},
]
}
]
}
];
}

@ -66,7 +66,11 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
required PlanRecurrentMedicalTaskRoomTabAttributes model,
required BuildContext context,
}) {
bool status = model.attributeValue;
bool status = model.attribute != null
? model.attributeValue == 'true'
? true
: false
: false;
String statusString = status ? 'Pass' : 'Fail';
return Row(
@ -85,7 +89,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
width: 41.toScreenWidth,
child: CupertinoSwitch(
thumbColor: status ? AppColor.green50 : AppColor.red30,
activeColor: AppColor.green30,
activeColor: AppColor.green30,
trackColor: AppColor.red80,
value: status,
onChanged: (state) {
@ -119,7 +123,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
model.attribute!.name!.bodyText2(context).custom(color: AppColor.white936, fontWeight: FontWeight.w500),
TextFormField(
keyboardType: TextInputType.number,
initialValue: model.attributeValue??'',
initialValue: model.attributeValue ?? '',
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(horizontal: 5.toScreenWidth),
filled: true,
@ -132,8 +136,8 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
enabledBorder: border,
focusedBorder: border,
),
onChanged: (value){
model.attributeValue=value;
onChanged: (value) {
model.attributeValue = value;
},
),
],

@ -15,10 +15,10 @@ import 'package:test_sa/service_request_latest/utilities/service_request_utils.d
import 'package:test_sa/views/widgets/requests/request_status.dart';
import 'package:test_sa/views/widgets/timer/app_timer.dart';
class RecurrentTaskAssetInfoWidget extends StatelessWidget {
class RecurrentTaskInfoWidget extends StatelessWidget {
final RecurrentWoData? model;
RecurrentTaskAssetInfoWidget({super.key, required this.model});
RecurrentTaskInfoWidget({super.key, required this.model});
@override
Widget build(BuildContext context) {

@ -1,5 +1,3 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
@ -9,10 +7,10 @@ import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/ppm/recurrent_wo.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/app_lazy_loading.dart';
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
import 'package:test_sa/service_request_latest/views/components/action_button/footer_action_button.dart';
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/asset_info_widget.dart';
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/dummy_data.dart';
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/task_info_widget.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
import '../../../../../../controllers/providers/api/all_requests_provider.dart';
@ -60,7 +58,7 @@ class _RecurrentWorkOrderViewState extends State<RecurrentWorkOrderView> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RecurrentTaskAssetInfoWidget(model: requestProvider.recurrentWoData),
RecurrentTaskInfoWidget(model: requestProvider.recurrentWoData),
// 8.height,
requestProvider.recurrentWoData!.planRecurrentMedicalTaskRooms!.isNotEmpty
? Column(
@ -114,22 +112,29 @@ void _updateTask({required BuildContext context, required int status}) async {
if(validate(model: allRequestsProvider.recurrentWoData!)){
allRequestsProvider.recurrentWoData?.planRecurrentTaskTimers = allRequestsProvider.recurrentWoData?.planRecurrentTaskTimers ?? [];
final workingHours = allRequestsProvider.recurrentWoData?.recurrentWoTimerModel?.startAt == null ? 0 : (allRequestsProvider.recurrentWoData?.recurrentWoTimerModel?.startAt ?? DateTime.now()).difference(allRequestsProvider.recurrentWoData!.recurrentWoTimerModel!.startAt!).inSeconds;
print('working hours is ${workingHours}');
return;
DateTime ?startTime = allRequestsProvider.recurrentWoData?.recurrentWoTimerModel?.startAt;
DateTime ?endTime = allRequestsProvider.recurrentWoData?.recurrentWoTimerModel?.endAt;
final duration = (endTime?.difference(startTime!));
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
allRequestsProvider.recurrentWoData?.planRecurrentTaskTimers?.add(
PlanRecurrentTaskTimers(
id: 0,
startTime: allRequestsProvider.recurrentWoData?.recurrentWoTimerModel?.startAt?.toIso8601String(),
endTime: allRequestsProvider.recurrentWoData?.recurrentWoTimerModel?.endAt?.toIso8601String(),
workingHours: ((allRequestsProvider.recurrentWoData?.recurrentWoTimerModel?.durationInSecond ?? 0) / 60 / 60),
startTime: startTime?.toIso8601String(),
endTime: endTime?.toIso8601String(),
workingHours: (duration?.inSeconds ?? 0) / 60 / 60,
),
);
await allRequestsProvider.updateRecurrentWo(
status: status,
);
Navigator.pop(context);
).whenComplete((){
if(status==1){// when click complete then this request remove from the list and status changes to closed..
//TODO some issues data not properly refreshed need to check waseem
allRequestsProvider.getAllRequests(context,typeTransaction: 5);
}
allRequestsProvider.recurrentWoData?.recurrentWoTimerModel=null;
Navigator.pop(context);
Navigator.pop(context);
});
}

Loading…
Cancel
Save