File tree Expand file tree Collapse file tree 4 files changed +27
-30
lines changed
java/com/kcn/hikvisionmanager Expand file tree Collapse file tree 4 files changed +27
-30
lines changed Original file line number Diff line number Diff line change 33import lombok .Builder ;
44import lombok .Data ;
55
6- import java .time .LocalDateTime ;
6+ import java .time .Duration ;
77
88@ Data
99@ Builder
@@ -15,9 +15,7 @@ public class CameraHealthDTO {
1515 private String status ;
1616 private String currentDeviceTime ;
1717
18- public String getFormattedUptime () {
19- if (uptimeMinutes < 60 ) return uptimeMinutes +" minutes" ;
20- if ((uptimeMinutes /60 ) < 24 ) return (uptimeMinutes /60 )+ " hours, " +(uptimeMinutes %60 )+" minutes" ;
21- return ((uptimeMinutes /60 ) / 24 ) + " days, " + (uptimeMinutes /60 )%24 + " hours, " + (uptimeMinutes %3600 ) + " minutes" ;
22- }
18+ private String formattedUptime ;
2319}
20+
21+
Original file line number Diff line number Diff line change 55import lombok .extern .slf4j .Slf4j ;
66import org .springframework .stereotype .Component ;
77
8+ import java .time .Duration ;
89import java .time .LocalDateTime ;
910import java .time .format .DateTimeFormatter ;
1011
@@ -21,8 +22,9 @@ public CameraHealthDTO toCameraHealthDTO(DeviceStatusXml deviceStatus) {
2122 .online (true )
2223 .cpuUsage (deviceStatus .getCpuList ().getCpu ().getCpuUtilization ())
2324 .memoryUsage (deviceStatus .getMemoryList ().getMemory ().getMemoryUsage ())
24- .uptimeMinutes (deviceStatus .getDeviceUpTime () / 60 )
25+ .uptimeMinutes (deviceStatus .getDeviceUpTime ()/ 60 )
2526 .status ("Connected" )
27+ .formattedUptime (getFormattedUptime (deviceStatus .getDeviceUpTime ()/60 ))
2628 .currentDeviceTime (parseDeviceTime (deviceStatus .getCurrentDeviceTime ()))
2729 .build ();
2830 }
@@ -46,4 +48,21 @@ private String parseDeviceTime(String deviceTime) {
4648 return null ;
4749 }
4850 }
51+
52+ public String getFormattedUptime (int uptimeMinutes ) {
53+ Duration duration = Duration .ofMinutes (uptimeMinutes );
54+
55+ long days = duration .toDays ();
56+ long hours = duration .toHoursPart ();
57+ long minutes = duration .toMinutesPart ();
58+
59+ if (days == 0 ) {
60+ if (hours == 0 ) {
61+ return minutes + " minutes" ;
62+ }
63+ return hours + " hours, " + minutes + " minutes" ;
64+ }
65+ return days + " days, " + hours + " hours, " + minutes + " minutes" ;
66+ }
67+
4968}
Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ public class TimeUtils {
1111 private static final ZoneId LOCAL_ZONE = ZoneId .systemDefault ();
1212
1313
14- // Format dla kamery (UTC)
14+ // Format (UTC)
1515 private static final DateTimeFormatter CAMERA_FORMAT =
1616 DateTimeFormatter .ofPattern ("yyyy-MM-dd'T'HH:mm:ss'Z'" );
1717
18- // Format dla UI (ISO Local DateTime) - TAKI JAK MASZ
18+ // Format dla UI (ISO Local DateTime)
1919 private static final DateTimeFormatter UI_FORMAT =
2020 DateTimeFormatter .ISO_LOCAL_DATE_TIME ; // "yyyy-MM-dd'T'HH:mm"
2121
@@ -36,24 +36,4 @@ public static LocalDateTime cameraUtcToLocal(String utcString) {
3636 return utcTime .atZoneSameInstant (LOCAL_ZONE ).toLocalDateTime ();
3737 }
3838
39- public static LocalDateTime cameraUtcToLocal (LocalDateTime utcTime ) {
40- if (utcTime == null ) return null ;
41- return utcTime .atOffset (ZoneOffset .UTC )
42- .atZoneSameInstant (LOCAL_ZONE )
43- .toLocalDateTime ();
44- }
45-
46- /**
47- * Formatowanie dla wyświetlania w UI (jeśli potrzebujesz)
48- */
49- public static String formatForDisplay (LocalDateTime localDateTime ) {
50- return localDateTime .format (UI_FORMAT ); // Zwraca "2025-10-29T16:00"
51- }
52-
53- /**
54- * Parsowanie z UI (jeśli potrzebujesz)
55- */
56- public static LocalDateTime parseFromUi (String uiDateTimeString ) {
57- return LocalDateTime .parse (uiDateTimeString , UI_FORMAT );
58- }
5939}
Original file line number Diff line number Diff line change 110110 GitHub
111111 </ a >
112112 < div class ="app-author ">
113- < span class ="app-author "> by < a href ="https://kcn333.pl " target ="_blank "> kCn</ a > © 2025</ span >
113+ < span class ="app-author "> by < a href ="https://kcn333.com " target ="_blank "> kCn</ a > © 2025</ span >
114114 </ div >
115115 </ div >
116116</ footer >
You can’t perform that action at this time.
0 commit comments