perf: 详细计算每装置每通道每预置位的图片数量和异常数

dev
huangfeng 3 months ago
parent 9473fea643
commit dc3444a7ab

@ -8,12 +8,9 @@ import java.util.List;
@Data
public class StatChannel {
Integer channelId;
List<StatPreset> presets;
List<StatPreset> 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;
}
}

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

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

@ -12,12 +12,9 @@ public class StatTerm {
int termId;
Object uploads;
String cmdid;
List<StatChannel> channels;
List<StatChannel> 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;
}
}

Loading…
Cancel
Save