|
|
@ -1,10 +1,14 @@
|
|
|
|
package com.shxy.xymanager_framework.timeTask;
|
|
|
|
package com.shxy.xymanager_framework.timeTask;
|
|
|
|
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalChannelMapper;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalChannelMapperExample;
|
|
|
|
import com.shxy.xymanager_common.entity.Terminals;
|
|
|
|
import com.shxy.xymanager_common.entity.Terminals;
|
|
|
|
import com.shxy.xymanager_common.model.TermChannelModel;
|
|
|
|
import com.shxy.xymanager_common.model.TermChannelModel;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalChannelMapperDao;
|
|
|
|
import com.shxy.xymanager_framework.socket.WebSocketServer;
|
|
|
|
import com.shxy.xymanager_framework.socket.WebSocketServer;
|
|
|
|
import com.shxy.xymanager_service.impl.TermSetServiceImpl;
|
|
|
|
import com.shxy.xymanager_service.impl.TermSetServiceImpl;
|
|
|
|
|
|
|
|
import com.shxy.xymanager_service.service.NewCacheService;
|
|
|
|
import com.shxy.xymanager_service.service.TerminalPhotoService;
|
|
|
|
import com.shxy.xymanager_service.service.TerminalPhotoService;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@ -14,6 +18,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
@ -21,41 +26,50 @@ import java.util.Map;
|
|
|
|
public class TermChannelTask {
|
|
|
|
public class TermChannelTask {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
TerminalPhotoService terminalPhotoService;
|
|
|
|
TerminalChannelMapperDao terminalChannelMapperDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
NewCacheService newCacheService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
WebSocketServer webSocketServer;
|
|
|
|
WebSocketServer webSocketServer;
|
|
|
|
|
|
|
|
|
|
|
|
//超时时间 分钟 5
|
|
|
|
//超时时间 分钟 5
|
|
|
|
Integer overtime = 1;
|
|
|
|
Integer overtime = 5;
|
|
|
|
|
|
|
|
|
|
|
|
//创建记录主动拍照参数
|
|
|
|
//创建记录主动拍照参数
|
|
|
|
// public static Map<String , TermChannelModel> termChannelModelMap = new HashMap<>();
|
|
|
|
// public static Map<String , TermChannelModel> termChannelModelMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(fixedDelay = 10000)
|
|
|
|
@Scheduled(fixedDelay = 30000)
|
|
|
|
public void queryTermChannelTime() {
|
|
|
|
public void queryTermChannelTime() {
|
|
|
|
Map<String , TermChannelModel> termChannelModelMap = TermSetServiceImpl.termChannelModelMap;
|
|
|
|
if (!TermSetServiceImpl.termChannelModelMap.isEmpty()) {
|
|
|
|
//获取当前系统时间
|
|
|
|
Iterator<String> iterator = TermSetServiceImpl.termChannelModelMap.keySet().iterator();
|
|
|
|
Long time = System.currentTimeMillis();
|
|
|
|
|
|
|
|
if ( !termChannelModelMap.isEmpty() ) {
|
|
|
|
|
|
|
|
Iterator<String> iterator = termChannelModelMap.keySet().iterator();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ( iterator.hasNext() ) {
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
String key = iterator.next();
|
|
|
|
String key = iterator.next();
|
|
|
|
TermChannelModel model = termChannelModelMap.get(key);
|
|
|
|
TermChannelModel model = TermSetServiceImpl.termChannelModelMap.get(key);
|
|
|
|
//开始拍照的时间 + 5分钟
|
|
|
|
//开始拍照的时间 + 5分钟
|
|
|
|
Long currentTime = model.getCurrentTime() + ( overtime * 60 * 1000);
|
|
|
|
Long currentTime = model.getCurrentTime() + (overtime * 60 * 1000);
|
|
|
|
if ( time >= currentTime ) {
|
|
|
|
if (System.currentTimeMillis() >= currentTime) {
|
|
|
|
iterator.remove();
|
|
|
|
iterator.remove();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
//调用查询最新照片
|
|
|
|
TerminalChannelMapperExample terminalChannelMapperExample = new TerminalChannelMapperExample();
|
|
|
|
Terminals terminals = terminalPhotoService.getTakePicPhotoStatus(model).getData();
|
|
|
|
TerminalChannelMapperExample.Criteria criteria = terminalChannelMapperExample.createCriteria();
|
|
|
|
if ( terminals.checkInclude() ) {
|
|
|
|
criteria.andTermIdEqualTo(model.getTermId());
|
|
|
|
|
|
|
|
criteria.andChannelIdEqualTo(model.getChannelId().byteValue());
|
|
|
|
|
|
|
|
//根据当前的装置id和通道id查询最新的图片时间
|
|
|
|
|
|
|
|
List<TerminalChannelMapper> terminalChannelMappers = terminalChannelMapperDao.selectByExample(terminalChannelMapperExample);
|
|
|
|
|
|
|
|
if (terminalChannelMappers.size() > 0) {
|
|
|
|
|
|
|
|
Long photoTime = terminalChannelMappers.get(0).getPhotoTime().longValue();
|
|
|
|
|
|
|
|
if (photoTime > model.getPhotoTime()) {
|
|
|
|
|
|
|
|
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap();
|
|
|
|
|
|
|
|
Terminals terminals = terminalMap.get(model.getTermId());
|
|
|
|
String str = "装置:" + terminals.getCmdid() + " 在通道" + model.getChannelId() + "拍的最新图片已上传";
|
|
|
|
String str = "装置:" + terminals.getCmdid() + " 在通道" + model.getChannelId() + "拍的最新图片已上传";
|
|
|
|
webSocketServer.sendNotice("photo",str);
|
|
|
|
webSocketServer.sendNotice("photo", str);
|
|
|
|
// System.out.println(str);
|
|
|
|
|
|
|
|
iterator.remove();
|
|
|
|
iterator.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|