perf: 调整动态计算前后时间误差范围

dev
huangfeng 2 months ago
parent 7cf862e5b8
commit b432c7e148

@ -218,6 +218,4 @@ public class Constants {
public static ConcurrentHashMap<Integer, Integer> scheduleRequestMap = new ConcurrentHashMap<>(); public static ConcurrentHashMap<Integer, Integer> scheduleRequestMap = new ConcurrentHashMap<>();
public static HashMap<Integer, String> scheduleRequestDoneMap = new HashMap<>(); public static HashMap<Integer, String> scheduleRequestDoneMap = new HashMap<>();
public static final Integer Photo_Schedule_Delay = 3;
} }

@ -37,13 +37,20 @@ public class ScheduleDetailsDto implements Serializable {
return hour * 60 + minute; return hour * 60 + minute;
} }
public boolean match(int min, int delay) { public boolean match(int min, int before, int delay) {
int cal = this.calMinute(); int cal = this.calMinute();
int r = Math.abs(min - cal); if (cal >= min) {
if (r <= delay) { if (cal - min <= before) {
return true; return true;
} else {
return false;
}
} else { } else {
return false; if (min - cal <= delay) {
return true;
} else {
return false;
}
} }
} }

@ -171,7 +171,6 @@ public class CameraSchedule {
} }
private List<ScheduleDetailsDto> list; private List<ScheduleDetailsDto> list;
private Integer delay;
public List<ScheduleDetailsDto> getList() { public List<ScheduleDetailsDto> getList() {
return list; return list;
@ -181,11 +180,4 @@ public class CameraSchedule {
this.list = list; this.list = list;
} }
public Integer getDelay() {
return delay;
}
public void setDelay(Integer delay) {
this.delay = delay;
}
} }

@ -10,7 +10,6 @@ import java.util.List;
@Data @Data
public class StatChannel { public class StatChannel {
Integer channelId; Integer channelId;
Integer delay;
List<StatPreset> presets = new ArrayList<>(); List<StatPreset> presets = new ArrayList<>();
public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) { public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) {
@ -24,7 +23,6 @@ public class StatChannel {
if (the == null) { if (the == null) {
the = new StatPreset(); the = new StatPreset();
the.setPresetId(photo.getPresetId()); the.setPresetId(photo.getPresetId());
the.setDelay(delay);
presets.add(the); presets.add(the);
} }
the.addPhoto(photo); the.addPhoto(photo);
@ -65,7 +63,6 @@ public class StatChannel {
if (the == null) { if (the == null) {
the = new StatPreset(); the = new StatPreset();
the.setPresetId(presetId); the.setPresetId(presetId);
the.setDelay(delay);
presets.add(the); presets.add(the);
} }
the.addSchedule(detail); the.addSchedule(detail);

@ -11,7 +11,6 @@ import java.util.List;
@Data @Data
public class StatPreset { public class StatPreset {
Integer presetId; Integer presetId;
Integer delay;
Integer total = 0; Integer total = 0;
List<ScheduleDetailsDto> scheduleList = new ArrayList<>(); List<ScheduleDetailsDto> scheduleList = new ArrayList<>();
List<Date> timeList = new ArrayList<>(); List<Date> timeList = new ArrayList<>();
@ -23,8 +22,23 @@ public class StatPreset {
int minute = calendar.get(Calendar.MINUTE); int minute = calendar.get(Calendar.MINUTE);
minute = hour * 60 + minute; minute = hour * 60 + minute;
total++; total++;
int before = 1;
int delay = 1;
if (scheduleList.size() < 49) {
before = 2;
delay = 25;
} else if (scheduleList.size() < 145) {
before = 1;
delay = 8;
} else if (scheduleList.size() < 289) {
before = 1;
delay = 3;
} else {
before = 0;
delay = 0;
}
for (ScheduleDetailsDto detail : scheduleList) { for (ScheduleDetailsDto detail : scheduleList) {
if (detail.match(minute, delay)) { if (detail.match(minute, before, delay)) {
detail.getTimeList().add(photo.getPhotoTime()); detail.getTimeList().add(photo.getPhotoTime());
return; return;
} }

@ -63,7 +63,6 @@ public class StatTerm {
if (the == null) { if (the == null) {
the = new StatChannel(); the = new StatChannel();
the.setChannelId(schedule.getChannelId()); the.setChannelId(schedule.getChannelId());
the.setDelay(schedule.getDelay());
channels.add(the); channels.add(the);
} }
the.initScheduleList(schedule.getList()); the.initScheduleList(schedule.getList());

@ -18,9 +18,6 @@ import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.shxy.xymanager_common.constant.Constants.Photo_Schedule_Delay;
@Service @Service
@Slf4j @Slf4j
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -73,7 +70,6 @@ public class CameraScheduleServiceImpl implements CameraScheduleService {
} }
private void processData(CameraSchedule item) throws Exception { private void processData(CameraSchedule item) throws Exception {
item.setDelay(Photo_Schedule_Delay);
if (StringUtils.isNotBlank(item.getData())) { if (StringUtils.isNotBlank(item.getData())) {
CameraScheduleModel model = JSONUtil.json2Object(item.getData(), CameraScheduleModel.class); CameraScheduleModel model = JSONUtil.json2Object(item.getData(), CameraScheduleModel.class);
List<ScheduleDetailsDto> list = model.getGroupData(); List<ScheduleDetailsDto> list = model.getGroupData();

Loading…
Cancel
Save