From e57ad74e5f106832b650c6343db0fea00090467c Mon Sep 17 00:00:00 2001 From: huangfeng Date: Thu, 24 Apr 2025 10:56:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A1=E7=AE=97=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=90=84=E4=B8=AA=E6=97=B6=E9=97=B4=E8=A1=A8=E7=9A=84=E7=85=A7?= =?UTF-8?q?=E7=89=87=E6=98=AF=E5=90=A6=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/ScheduleDetailsDto.java | 28 +++++++++++++++++++ .../xymanager_common/model/StatChannel.java | 4 +-- .../xymanager_common/model/StatPreset.java | 20 +++++++++++-- .../shxy/xymanager_common/model/StatTerm.java | 5 ++-- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/ScheduleDetailsDto.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/ScheduleDetailsDto.java index 2caa9bb..3d5f356 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/ScheduleDetailsDto.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/ScheduleDetailsDto.java @@ -4,6 +4,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) @Data @@ -20,6 +23,8 @@ public class ScheduleDetailsDto implements Serializable { private static final long serialVersionUID = 1L; + List timeList = new ArrayList<>(); + public void initMinute(int min) { hour = min / 60; minute = min - hour * 60; @@ -32,4 +37,27 @@ public class ScheduleDetailsDto implements Serializable { return hour * 60 + minute; } + public boolean match(int min, int delay) { + int cal = this.calMinute(); + if (cal == min) { + return true; + } else if (cal > min) { + return false; + } else { + if (cal + delay >= min) { + return true; + } else { + return false; + } + } + } + + public boolean isWrong() { + if (timeList.size() == 1) { + return false; + } else { + return true; + } + } + } \ No newline at end of file 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 e59fd52..e271a3d 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 @@ -30,10 +30,10 @@ public class StatChannel { the.addPhoto(photo); } - public int getTotal() { + public int getRedundant() { int total = 0; for (StatPreset item : presets) { - total = total + item.getTotal(); + total = total + item.getRedundant(); } return total; } 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 96c4d6f..f2095cb 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 @@ -1,10 +1,10 @@ package com.shxy.xymanager_common.model; import com.shxy.xymanager_common.dto.ScheduleDetailsDto; -import com.shxy.xymanager_common.util.DateUtil; import lombok.Data; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.List; @@ -16,15 +16,31 @@ public class StatPreset { List timeList = new ArrayList<>(); public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(photo.getPhotoTime()); + int hour = calendar.get(Calendar.HOUR_OF_DAY); + int minute = calendar.get(Calendar.MINUTE); + minute = hour * 60 + minute; + for (ScheduleDetailsDto detail : scheduleList) { + if (detail.match(minute, delay)) { + detail.getTimeList().add(photo.getPhotoTime()); + return; + } + } timeList.add(photo.getPhotoTime()); } - public int getTotal() { + public int getRedundant() { return timeList.size(); } public int getWrongCount() { int count = 0; + for (ScheduleDetailsDto detail : scheduleList) { + if (detail.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 0f09b0a..8054019 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 @@ -1,7 +1,6 @@ package com.shxy.xymanager_common.model; import com.fasterxml.jackson.annotation.JsonInclude; -import com.shxy.xymanager_common.dto.ScheduleDetailsDto; import com.shxy.xymanager_common.entity.CameraSchedule; import lombok.Data; import org.springframework.util.CollectionUtils; @@ -33,10 +32,10 @@ public class StatTerm { the.addPhoto(photo); } - public int getTotal() { + public int getRedundant() { int total = 0; for (StatChannel item : channels) { - total = total + item.getTotal(); + total = total + item.getRedundant(); } return total; }