From dc3444a7ab8424add6030bc988fc3ce0077e0825 Mon Sep 17 00:00:00 2001 From: huangfeng Date: Wed, 26 Mar 2025 14:46:29 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=AF=A6=E7=BB=86=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=AF=8F=E8=A3=85=E7=BD=AE=E6=AF=8F=E9=80=9A=E9=81=93=E6=AF=8F?= =?UTF-8?q?=E9=A2=84=E7=BD=AE=E4=BD=8D=E7=9A=84=E5=9B=BE=E7=89=87=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=92=8C=E5=BC=82=E5=B8=B8=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xymanager_common/model/StatChannel.java | 21 ++++++++-- .../shxy/xymanager_common/model/StatHour.java | 29 ++++++++++++++ .../xymanager_common/model/StatPreset.java | 40 ++++++++++++++++--- .../shxy/xymanager_common/model/StatTerm.java | 21 ++++++++-- 4 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatHour.java diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatChannel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatChannel.java index e7b62a2..d08e33f 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatChannel.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatChannel.java @@ -8,12 +8,9 @@ import java.util.List; @Data public class StatChannel { Integer channelId; - List presets; + List presets = new ArrayList<>(); public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) { - if (presets == null) { - presets = new ArrayList<>(); - } StatPreset the = null; for (StatPreset item : presets) { if (item.getPresetId().intValue() == photo.getPresetId().intValue()) { @@ -28,4 +25,20 @@ public class StatChannel { } the.addPhoto(photo); } + + public int getTotal() { + int total = 0; + for (StatPreset item : presets) { + total = total + item.getTotal(); + } + return total; + } + + public int getWrongCount() { + int count = 0; + for (StatPreset item : presets) { + count = count + item.getWrongCount(); + } + return count; + } } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatHour.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatHour.java new file mode 100644 index 0000000..011360f --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatHour.java @@ -0,0 +1,29 @@ +package com.shxy.xymanager_common.model; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Data +public class StatHour { + Integer hour; + List photoTimes = new ArrayList<>(); + + public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) { + photoTimes.add(photo.getPhotoTime()); + } + + public boolean isWrong() { + if (photoTimes.size() == 2) { + return false; + } else { + return true; + } + } + + public int getTotal() { + return photoTimes.size(); + } +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatPreset.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatPreset.java index 1c55d41..5017771 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatPreset.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatPreset.java @@ -3,18 +3,48 @@ package com.shxy.xymanager_common.model; import lombok.Data; import java.util.ArrayList; -import java.util.Date; +import java.util.Calendar; import java.util.List; @Data public class StatPreset { Integer presetId; - List photoTimes; + List hours = new ArrayList<>(); public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) { - if (photoTimes == null) { - photoTimes = new ArrayList<>(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(photo.getPhotoTime()); + int hour = calendar.get(Calendar.HOUR_OF_DAY); + StatHour the = null; + for (StatHour item : hours) { + if (item.getHour().intValue() == hour) { + the = item; + break; + } } - photoTimes.add(photo.getPhotoTime()); + if (the == null) { + the = new StatHour(); + the.setHour(hour); + hours.add(the); + } + the.addPhoto(photo); + } + + public int getTotal() { + int total = 0; + for (StatHour item : hours) { + total = total + item.getTotal(); + } + return total; + } + + public int getWrongCount() { + int count = 0; + for (StatHour item : hours) { + if (item.isWrong()) { + count++; + } + } + return count; } } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java index 720b0ab..317962d 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/StatTerm.java @@ -12,12 +12,9 @@ public class StatTerm { int termId; Object uploads; String cmdid; - List channels; + List channels = new ArrayList<>(); public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) { - if (channels == null) { - channels = new ArrayList<>(); - } StatChannel the = null; for (StatChannel item : channels) { if (item.getChannelId().intValue() == photo.getChannelid().intValue()) { @@ -32,4 +29,20 @@ public class StatTerm { } the.addPhoto(photo); } + + public int getTotal() { + int total = 0; + for (StatChannel item : channels) { + total = total + item.getTotal(); + } + return total; + } + + public int getWrongCount() { + int count = 0; + for (StatChannel item : channels) { + count = count + item.getWrongCount(); + } + return count; + } }