|
|
|
@ -1,33 +1,56 @@
|
|
|
|
|
package com.shxy.xymanager_framework.timeTask;
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.constant.Constants;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TermAndChannelDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TermChannelAndMapperDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.CameraSchedule;
|
|
|
|
|
import com.shxy.xymanager_common.entity.CameraScheduleExample;
|
|
|
|
|
import com.shxy.xymanager_common.entity.RequestResults;
|
|
|
|
|
import com.shxy.xymanager_common.entity.Terminals;
|
|
|
|
|
import com.shxy.xymanager_common.vo.TermCtrlVo;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.CameraScheduleMapper;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.RequestResultsDao;
|
|
|
|
|
import com.shxy.xymanager_service.service.CacheService;
|
|
|
|
|
import com.shxy.xymanager_service.service.NewCacheService;
|
|
|
|
|
import com.shxy.xymanager_service.service.TermSetService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PreDestroy;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class StoreCameraScheduleTask {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
NewCacheService newCacheService;
|
|
|
|
|
@Resource
|
|
|
|
|
CacheService cacheService;
|
|
|
|
|
@Resource
|
|
|
|
|
RequestResultsDao requestResultsDao;
|
|
|
|
|
@Resource
|
|
|
|
|
CameraScheduleMapper cameraScheduleMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
TermSetService termSetService;
|
|
|
|
|
|
|
|
|
|
private int shutdown = 0;
|
|
|
|
|
|
|
|
|
|
@PreDestroy
|
|
|
|
|
private void preDestroy() {
|
|
|
|
|
shutdown = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Scheduled(initialDelay = 60000, fixedDelay = 60000)
|
|
|
|
|
private void store() {
|
|
|
|
|
Iterator<Integer> it = Constants.scheduleRequestMap.keySet().iterator();
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
while (shutdown == 0 && it.hasNext()) {
|
|
|
|
|
Integer requestid = it.next();
|
|
|
|
|
RequestResults results = requestResultsDao.selectByRequestId(requestid);
|
|
|
|
|
if (results != null) {
|
|
|
|
@ -63,6 +86,54 @@ public class StoreCameraScheduleTask {
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 1 3 * * ?")
|
|
|
|
|
private void search() {
|
|
|
|
|
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap();
|
|
|
|
|
Map<Integer, TermAndChannelDto> termAndChannelMap = cacheService.getTermAndChannelMap();
|
|
|
|
|
Iterator<Integer> it = terminalMap.keySet().iterator();
|
|
|
|
|
while (shutdown == 0 && it.hasNext()) {
|
|
|
|
|
Integer termId = it.next();
|
|
|
|
|
Terminals term = terminalMap.get(termId);
|
|
|
|
|
TermAndChannelDto termAndChannelDto = termAndChannelMap.get(termId);
|
|
|
|
|
this.searchOne(term, termAndChannelDto);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(500);
|
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void searchOne(Terminals term, TermAndChannelDto termAndChannelDto) {
|
|
|
|
|
if (termAndChannelDto == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
List<TermChannelAndMapperDto> channelList = termAndChannelDto.getList();
|
|
|
|
|
if (CollectionUtils.isEmpty(channelList)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (TermChannelAndMapperDto item : channelList) {
|
|
|
|
|
TermCtrlVo vo = new TermCtrlVo();
|
|
|
|
|
vo.setTermId(term.getId());
|
|
|
|
|
List<TermCtrlVo.CtrlBean> list = new ArrayList<>();
|
|
|
|
|
TermCtrlVo.CtrlBean bean = new TermCtrlVo.CtrlBean();
|
|
|
|
|
bean.setName("act");
|
|
|
|
|
bean.setValue("schedule");
|
|
|
|
|
list.add(bean);
|
|
|
|
|
bean = new TermCtrlVo.CtrlBean();
|
|
|
|
|
bean.setName("udp");
|
|
|
|
|
bean.setValue("1");
|
|
|
|
|
list.add(bean);
|
|
|
|
|
bean = new TermCtrlVo.CtrlBean();
|
|
|
|
|
bean.setName("flag");
|
|
|
|
|
bean.setValue("0");
|
|
|
|
|
list.add(bean);
|
|
|
|
|
bean = new TermCtrlVo.CtrlBean();
|
|
|
|
|
bean.setName("channel");
|
|
|
|
|
bean.setValue(String.valueOf(item.getChannelid()));
|
|
|
|
|
list.add(bean);
|
|
|
|
|
vo.setList(list);
|
|
|
|
|
try {
|
|
|
|
|
termSetService.setTermCamera(vo);
|
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|