|
|
|
@ -1,16 +1,21 @@
|
|
|
|
|
package com.shxy.xymanager_service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.dto.ScheduleDetailsDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.CameraSchedule;
|
|
|
|
|
import com.shxy.xymanager_common.entity.CameraScheduleExample;
|
|
|
|
|
import com.shxy.xymanager_common.model.CameraScheduleModel;
|
|
|
|
|
import com.shxy.xymanager_common.util.JSONUtil;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.CameraScheduleMapper;
|
|
|
|
|
import com.shxy.xymanager_service.service.CameraScheduleService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,7 +28,7 @@ public class CameraScheduleServiceImpl implements CameraScheduleService {
|
|
|
|
|
CameraScheduleMapper mapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public CameraSchedule getOne(Integer termId, Integer channel) {
|
|
|
|
|
public CameraSchedule getOne(Integer termId, Integer channel) throws Exception {
|
|
|
|
|
CameraSchedule result = null;
|
|
|
|
|
CameraScheduleExample example = new CameraScheduleExample();
|
|
|
|
|
CameraScheduleExample.Criteria criteria = example.createCriteria();
|
|
|
|
@ -32,18 +37,68 @@ public class CameraScheduleServiceImpl implements CameraScheduleService {
|
|
|
|
|
List<CameraSchedule> list = mapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
|
result = list.get(0);
|
|
|
|
|
this.processData(result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<CameraSchedule> list(Integer termId) {
|
|
|
|
|
public List<CameraSchedule> list(Integer termId) throws Exception {
|
|
|
|
|
CameraScheduleExample example = new CameraScheduleExample();
|
|
|
|
|
CameraScheduleExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
if (termId != null) {
|
|
|
|
|
criteria.andTermIdEqualTo(termId);
|
|
|
|
|
}
|
|
|
|
|
List<CameraSchedule> list = mapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
for (CameraSchedule item : list) {
|
|
|
|
|
this.processData(item);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<CameraSchedule> list(List<Integer> termIdList) throws Exception {
|
|
|
|
|
CameraScheduleExample example = new CameraScheduleExample();
|
|
|
|
|
CameraScheduleExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
if (termIdList != null) {
|
|
|
|
|
criteria.andTermIdIn(termIdList);
|
|
|
|
|
}
|
|
|
|
|
List<CameraSchedule> list = mapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
for (CameraSchedule item : list) {
|
|
|
|
|
this.processData(item);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void processData(CameraSchedule item) throws Exception {
|
|
|
|
|
if (StringUtils.isNotBlank(item.getData())) {
|
|
|
|
|
CameraScheduleModel model = JSONUtil.json2Object(item.getData(), CameraScheduleModel.class);
|
|
|
|
|
List<ScheduleDetailsDto> list = model.getGroupData();
|
|
|
|
|
if (item.getProtocol() == 65290 || item.getProtocol() == 65298) {
|
|
|
|
|
list = this.changeSchedule(list);
|
|
|
|
|
}
|
|
|
|
|
item.setList(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ScheduleDetailsDto> changeSchedule(List<ScheduleDetailsDto> list) {
|
|
|
|
|
if (list.size() != 3) {
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
ScheduleDetailsDto first = list.get(0);
|
|
|
|
|
ScheduleDetailsDto second = list.get(1);
|
|
|
|
|
ScheduleDetailsDto third = list.get(2);
|
|
|
|
|
int interval = first.getHour() * 60 + first.getMinute();
|
|
|
|
|
int start = second.getHour() * 60 + second.getMinute();
|
|
|
|
|
int end = third.getHour() * 60 + third.getMinute();
|
|
|
|
|
|
|
|
|
|
List<ScheduleDetailsDto> result = new ArrayList<>();
|
|
|
|
|
while (start < end) {
|
|
|
|
|
ScheduleDetailsDto item = new ScheduleDetailsDto();
|
|
|
|
|
item.initMinute(start);
|
|
|
|
|
result.add(item);
|
|
|
|
|
start = start + interval;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|