feat: 计算统计各个时间表的照片是否正常

dev
huangfeng 2 months ago
parent 3d178c47af
commit e57ad74e5f

@ -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<Date> 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;
}
}
}

@ -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;
}

@ -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<Date> 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;
}

@ -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;
}

Loading…
Cancel
Save