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 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;
}
public boolean match(int min, int delay) {
public boolean match(int min, int before, int delay) {
int cal = this.calMinute();
int r = Math.abs(min - cal);
if (r <= delay) {
return true;
if (cal >= min) {
if (cal - min <= before) {
return true;
} else {
return false;
}
} else {
return false;
if (min - cal <= delay) {
return true;
} else {
return false;
}
}
}

@ -171,7 +171,6 @@ public class CameraSchedule {
}
private List<ScheduleDetailsDto> list;
private Integer delay;
public List<ScheduleDetailsDto> getList() {
return list;
@ -181,11 +180,4 @@ public class CameraSchedule {
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
public class StatChannel {
Integer channelId;
Integer delay;
List<StatPreset> presets = new ArrayList<>();
public void addPhoto(TerminalPhotoSelectListModel.PhotoBean photo) {
@ -24,7 +23,6 @@ public class StatChannel {
if (the == null) {
the = new StatPreset();
the.setPresetId(photo.getPresetId());
the.setDelay(delay);
presets.add(the);
}
the.addPhoto(photo);
@ -65,7 +63,6 @@ public class StatChannel {
if (the == null) {
the = new StatPreset();
the.setPresetId(presetId);
the.setDelay(delay);
presets.add(the);
}
the.addSchedule(detail);

@ -11,7 +11,6 @@ import java.util.List;
@Data
public class StatPreset {
Integer presetId;
Integer delay;
Integer total = 0;
List<ScheduleDetailsDto> scheduleList = new ArrayList<>();
List<Date> timeList = new ArrayList<>();
@ -23,8 +22,23 @@ public class StatPreset {
int minute = calendar.get(Calendar.MINUTE);
minute = hour * 60 + minute;
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) {
if (detail.match(minute, delay)) {
if (detail.match(minute, before, delay)) {
detail.getTimeList().add(photo.getPhotoTime());
return;
}

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

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

Loading…
Cancel
Save