diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index 7f8a61e9..9b1ef1e3 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -5,8 +5,8 @@ class URLs { // static const host1 = "https://atomsm.hmg.com"; // production url // static const host1 = "https://atomsmdev.hmg.com"; // local DEV url - // static const host1 = "https://atomsmuat.hmg.com"; // local UAT url - static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url + static const host1 = "https://atomsmuat.hmg.com"; // local UAT url + // static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url // static String _baseUrl = "$_host/mobile"; static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis @@ -263,7 +263,9 @@ class URLs { //Traf static get addTRAF => "$_baseUrl/TRAF/AddTRAF"; // get static get getTRAFById => "$_baseUrl/TRAF/GetTRAFById"; // get + static get getAssetAnalytics => "$_baseUrl/Asset/GetAssetAnalytics"; // get static get getAssetNDAutoCompleteByDynamicCodes => "$_baseUrl/AssetNameDefinition/GetAssetNDAutoCompleteByDynamicCodes"; // get// get + static get getAssetNameAutoComplete => "$_baseUrl/AssetNameDefinition/GetAssetNameAutoComplete"; // get// get //gas refill static get getGasTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=606"; // get @@ -300,6 +302,7 @@ class URLs { static get getNurses => "$_baseUrl/Account/GetUserByRoleValue?value=R-7"; // get static get getNursesBySiteId => "$_baseUrl/Account/GetUserByRoleValueSiteAndAssetGroupBySiteId?value=R-7"; // get static get getUsersBasedOnSearch => "$_baseUrl/Account/GetUsersBasedOnSearch"; // get + static get getUserByRoleValueSiteMobileAutocomplete => "$_baseUrl/Account/GetUserByRoleValueSiteMobileAutocomplete"; // get // pentry static get getPentry => "$_baseUrl/return/pentry/details"; // get diff --git a/lib/controllers/providers/api/oracle_code_provider.dart b/lib/controllers/providers/api/oracle_code_provider.dart index ea8b0978..71375675 100644 --- a/lib/controllers/providers/api/oracle_code_provider.dart +++ b/lib/controllers/providers/api/oracle_code_provider.dart @@ -88,7 +88,7 @@ class OracleCodeProvider extends ChangeNotifier { Future> getAssetByOracleCode(String oracleCode) async { late Response response; try { - response = await ApiManager.instance.post(URLs.getAssetNDAutoCompleteByDynamicCodes, body: {"codeValue": oracleCode}); + response = await ApiManager.instance.post(URLs.getAssetNameAutoComplete, body: {"pageSize": 1, "pageNumber": 20, "searchText": oracleCode}); List page = []; if (response.statusCode >= 200 && response.statusCode < 300) { // client's request was successfully received diff --git a/lib/controllers/providers/api/search_user_provider.dart b/lib/controllers/providers/api/search_user_provider.dart index cdaecdb2..e29b1487 100644 --- a/lib/controllers/providers/api/search_user_provider.dart +++ b/lib/controllers/providers/api/search_user_provider.dart @@ -49,7 +49,7 @@ class UserSearchProvider extends ChangeNotifier { Future> getUsersBasedOnSearch(String query) async { late Response response; try { - response = await ApiManager.instance.get(URLs.getUsersBasedOnSearch + "?roleValue=R-7&searchText=$query"); + response = await ApiManager.instance.get(URLs.getUserByRoleValueSiteMobileAutocomplete + "?siteId=1&roleValue=R-7&searchText=$query"); List page = []; if (response.statusCode >= 200 && response.statusCode < 300) { // client's request was successfully received diff --git a/lib/modules/traf_module/asset_analytics_model.dart b/lib/modules/traf_module/asset_analytics_model.dart new file mode 100644 index 00000000..2f265c1b --- /dev/null +++ b/lib/modules/traf_module/asset_analytics_model.dart @@ -0,0 +1,172 @@ +class AssetAnalytics { + num? assetId; + String? assetNumber; + String? assetName; + num? lastPrice; + String? lastPONo; + String? lastPODate; + num? sameAssetQuantity; + String? slaStatus; + String? contractNumber; + String? contractStartDate; + String? contractEndDate; + num? assetAgeInDays; + String? assetAgeDescription; + num? totalMaintenanceCost; + num? sparePartCost; + num? laborCost; + num? exchangeCost; + num? travelCost; + num? netBookValue; + num? purchasedPrice; + num? lifeSpan; + num? mtbf; + String? mtbfDescription; + num? totalCMWorkOrders; + num? downTimeHours; + String? downTimeDescription; + num? upTimeHours; + String? upTimeDescription; + num? operationHours; + String? installationDate; + String? modelName; + String? manufacturerName; + String? serialNumber; + String? departmentName; + String? siteName; + num? id; + String? createdBy; + String? createdDate; + String? modifiedBy; + String? modifiedDate; + + AssetAnalytics( + {this.assetId, + this.assetNumber, + this.assetName, + this.lastPrice, + this.lastPONo, + this.lastPODate, + this.sameAssetQuantity, + this.slaStatus, + this.contractNumber, + this.contractStartDate, + this.contractEndDate, + this.assetAgeInDays, + this.assetAgeDescription, + this.totalMaintenanceCost, + this.sparePartCost, + this.laborCost, + this.exchangeCost, + this.travelCost, + this.netBookValue, + this.purchasedPrice, + this.lifeSpan, + this.mtbf, + this.mtbfDescription, + this.totalCMWorkOrders, + this.downTimeHours, + this.downTimeDescription, + this.upTimeHours, + this.upTimeDescription, + this.operationHours, + this.installationDate, + this.modelName, + this.manufacturerName, + this.serialNumber, + this.departmentName, + this.siteName, + this.id, + this.createdBy, + this.createdDate, + this.modifiedBy, + this.modifiedDate}); + + AssetAnalytics.fromJson(Map json) { + assetId = json['assetId']; + assetNumber = json['assetNumber']; + assetName = json['assetName']; + lastPrice = json['lastPrice']; + lastPONo = json['lastPONo']; + lastPODate = json['lastPODate']; + sameAssetQuantity = json['sameAssetQuantity']; + slaStatus = json['slaStatus']; + contractNumber = json['contractNumber']; + contractStartDate = json['contractStartDate']; + contractEndDate = json['contractEndDate']; + assetAgeInDays = json['assetAgeInDays']; + assetAgeDescription = json['assetAgeDescription']; + totalMaintenanceCost = json['totalMaintenanceCost']; + sparePartCost = json['sparePartCost']; + laborCost = json['laborCost']; + exchangeCost = json['exchangeCost']; + travelCost = json['travelCost']; + netBookValue = json['netBookValue']; + purchasedPrice = json['purchasedPrice']; + lifeSpan = json['lifeSpan']; + mtbf = json['mtbf']; + mtbfDescription = json['mtbfDescription']; + totalCMWorkOrders = json['totalCMWorkOrders']; + downTimeHours = json['downTimeHours']; + downTimeDescription = json['downTimeDescription']; + upTimeHours = json['upTimeHours']; + upTimeDescription = json['upTimeDescription']; + operationHours = json['operationHours']; + installationDate = json['installationDate']; + modelName = json['modelName']; + manufacturerName = json['manufacturerName']; + serialNumber = json['serialNumber']; + departmentName = json['departmentName']; + siteName = json['siteName']; + id = json['id']; + createdBy = json['createdBy']; + createdDate = json['createdDate']; + modifiedBy = json['modifiedBy']; + modifiedDate = json['modifiedDate']; + } + + Map toJson() { + final Map data = new Map(); + data['assetId'] = this.assetId; + data['assetNumber'] = this.assetNumber; + data['assetName'] = this.assetName; + data['lastPrice'] = this.lastPrice; + data['lastPONo'] = this.lastPONo; + data['lastPODate'] = this.lastPODate; + data['sameAssetQuantity'] = this.sameAssetQuantity; + data['slaStatus'] = this.slaStatus; + data['contractNumber'] = this.contractNumber; + data['contractStartDate'] = this.contractStartDate; + data['contractEndDate'] = this.contractEndDate; + data['assetAgeInDays'] = this.assetAgeInDays; + data['assetAgeDescription'] = this.assetAgeDescription; + data['totalMaintenanceCost'] = this.totalMaintenanceCost; + data['sparePartCost'] = this.sparePartCost; + data['laborCost'] = this.laborCost; + data['exchangeCost'] = this.exchangeCost; + data['travelCost'] = this.travelCost; + data['netBookValue'] = this.netBookValue; + data['purchasedPrice'] = this.purchasedPrice; + data['lifeSpan'] = this.lifeSpan; + data['mtbf'] = this.mtbf; + data['mtbfDescription'] = this.mtbfDescription; + data['totalCMWorkOrders'] = this.totalCMWorkOrders; + data['downTimeHours'] = this.downTimeHours; + data['downTimeDescription'] = this.downTimeDescription; + data['upTimeHours'] = this.upTimeHours; + data['upTimeDescription'] = this.upTimeDescription; + data['operationHours'] = this.operationHours; + data['installationDate'] = this.installationDate; + data['modelName'] = this.modelName; + data['manufacturerName'] = this.manufacturerName; + data['serialNumber'] = this.serialNumber; + data['departmentName'] = this.departmentName; + data['siteName'] = this.siteName; + data['id'] = this.id; + data['createdBy'] = this.createdBy; + data['createdDate'] = this.createdDate; + data['modifiedBy'] = this.modifiedBy; + data['modifiedDate'] = this.modifiedDate; + return data; + } +} diff --git a/lib/modules/traf_module/traf_request_detail_page.dart b/lib/modules/traf_module/traf_request_detail_page.dart index 3eac9725..00f25512 100644 --- a/lib/modules/traf_module/traf_request_detail_page.dart +++ b/lib/modules/traf_module/traf_request_detail_page.dart @@ -15,6 +15,7 @@ import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/views/widgets/loaders/app_loading.dart'; import 'package:test_sa/views/widgets/loaders/no_data_found.dart'; +import 'asset_analytics_model.dart'; import 'traf_request_model.dart'; class TrafRequestDetailPage extends StatefulWidget { @@ -165,16 +166,29 @@ class _TrafRequestDetailPageState extends State { '${context.translation.model}: ${data.modelName ?? '-'}'.bodyText(context), '${context.translation.manufacture}: ${data.manufacturerName ?? '-'}'.bodyText(context), if (data.requestTypeId == 733) ...[ - 'Last price & PO: ${data.poNumber ?? '-'}'.bodyText(context), - 'The quantity of the same asset: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Existing asset under SLA: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Age of the asset: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Total Maintenance Cost (TMC): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Net Book Value (NBV): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Mean Time Between Failure (MTBF): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Down Time (DT): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Up Time (UT): ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer - 'Purchased Price: ${data.qty ?? '-'}'.bodyText(context), // todo check with shaheer + FutureBuilder( + future: Provider.of(context, listen: false).getAssetAnalytics(data.assetId!), + builder: (cxt, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const SizedBox.square(dimension: 24, child: CircularProgressIndicator()).center; + } + if (snapshot.hasData) { + return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + 'Last price: ${snapshot.data?.lastPrice ?? '-'}'.bodyText(context), + 'PO: ${snapshot.data?.lastPONo ?? '-'}'.bodyText(context), + 'The quantity of the same asset: ${snapshot.data?.sameAssetQuantity ?? '-'}'.bodyText(context), // todo check with shaheer + 'Existing asset under SLA: ${snapshot.data?.slaStatus ?? '-'}'.bodyText(context), // todo check with shaheer + 'Age of the asset: ${snapshot.data?.assetAgeDescription ?? '-'}'.bodyText(context), // todo check with shaheer + 'Total Maintenance Cost (TMC): ${snapshot.data?.totalMaintenanceCost ?? '-'}'.bodyText(context), // todo check with shaheer + 'Net Book Value (NBV): ${snapshot.data?.netBookValue ?? '-'}'.bodyText(context), // todo check with shaheer + 'Mean Time Between Failure (MTBF): ${snapshot.data?.mtbfDescription ?? '-'}'.bodyText(context), // todo check with shaheer + 'Down Time (DT): ${snapshot.data?.downTimeDescription ?? '-'}'.bodyText(context), // todo check with shaheer + 'Up Time (UT): ${snapshot.data?.upTimeDescription ?? '-'}'.bodyText(context), + 'Purchased Price: ${snapshot.data?.purchasedPrice ?? '-'}'.bodyText(context), + ]); + } + return const SizedBox(); + }) ], ], ).toShadowContainer(context, borderRadius: 20, padding: 12); diff --git a/lib/modules/traf_module/traf_request_provider.dart b/lib/modules/traf_module/traf_request_provider.dart index 3626eab0..346f7351 100644 --- a/lib/modules/traf_module/traf_request_provider.dart +++ b/lib/modules/traf_module/traf_request_provider.dart @@ -5,6 +5,7 @@ import 'package:http/http.dart'; import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; +import 'asset_analytics_model.dart'; import 'traf_request_model.dart'; class TrafRequestProvider extends ChangeNotifier { @@ -43,4 +44,16 @@ class TrafRequestProvider extends ChangeNotifier { return -1; } } + + Future getAssetAnalytics(int assetId) async { + try { + Response response = await ApiManager.instance.get("${URLs.getAssetAnalytics}?assetId=$assetId"); + if (response.statusCode >= 200 && response.statusCode < 300) { + return AssetAnalytics.fromJson(json.decode(response.body)["data"]); + } + } catch (error) { + print(error); + } + return null; + } } diff --git a/lib/modules/traf_module/users_auto_complete_field.dart b/lib/modules/traf_module/users_auto_complete_field.dart index f05e77fa..eae48e41 100644 --- a/lib/modules/traf_module/users_auto_complete_field.dart +++ b/lib/modules/traf_module/users_auto_complete_field.dart @@ -87,7 +87,7 @@ class _UsersAutoCompleteFieldState extends State { }); return workOrders; }, - displayStringForOption: (UsersBasedOnSearchModel option) => widget.byName ? "${option.userName ?? "-"} (${option.position ?? "-"})" ?? "" : option.employeeId ?? "", + displayStringForOption: (UsersBasedOnSearchModel option) => widget.byName ? "${option.userName ?? "-"} (Nurse)" ?? "" : option.employeeId ?? "", fieldViewBuilder: (BuildContext context, TextEditingController fieldTextEditingController, FocusNode fieldFocusNode, VoidCallback onFieldSubmitted) { return TextField( controller: _controller,