feat:主动拍照增加定时任务推送通知
parent
5bc859e5f4
commit
fb7ed2cf50
@ -0,0 +1,28 @@
|
||||
package com.shxy.xymanager_common.model;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "记录拍照装置通道信息", description = "记录拍照装置通道信息描述")
|
||||
public class TermChannelModel implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "装置id", example = "123456")
|
||||
private Integer termId;
|
||||
|
||||
@ApiModelProperty(value = "通道id", example = "123456")
|
||||
private Integer channelId;
|
||||
|
||||
@ApiModelProperty(value = "拍照时间", example = "123456")
|
||||
private Long photoTime;
|
||||
|
||||
@ApiModelProperty(value = "当前时间", example = "123456")
|
||||
private Long currentTime;
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.shxy.xymanager_framework.timeTask;
|
||||
|
||||
import com.shxy.xymanager_common.bean.ServiceBody;
|
||||
import com.shxy.xymanager_common.entity.Terminals;
|
||||
import com.shxy.xymanager_common.model.TermChannelModel;
|
||||
import com.shxy.xymanager_framework.socket.WebSocketServer;
|
||||
import com.shxy.xymanager_service.impl.TermSetServiceImpl;
|
||||
import com.shxy.xymanager_service.service.TerminalPhotoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TermChannelTask {
|
||||
|
||||
@Autowired
|
||||
TerminalPhotoService terminalPhotoService;
|
||||
|
||||
@Resource
|
||||
WebSocketServer webSocketServer;
|
||||
|
||||
//超时时间 分钟 5
|
||||
Integer overtime = 1;
|
||||
|
||||
//创建记录主动拍照参数
|
||||
// public static Map<String , TermChannelModel> termChannelModelMap = new HashMap<>();
|
||||
|
||||
@Scheduled(fixedDelay = 10000)
|
||||
public void queryTermChannelTime() {
|
||||
Map<String , TermChannelModel> termChannelModelMap = TermSetServiceImpl.termChannelModelMap;
|
||||
//获取当前系统时间
|
||||
Long time = System.currentTimeMillis();
|
||||
if ( !termChannelModelMap.isEmpty() ) {
|
||||
Iterator<String> iterator = termChannelModelMap.keySet().iterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
String key = iterator.next();
|
||||
TermChannelModel model = termChannelModelMap.get(key);
|
||||
//开始拍照的时间 + 5分钟
|
||||
Long currentTime = model.getCurrentTime() + ( overtime * 60 * 1000);
|
||||
if ( time >= currentTime ) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
//调用查询最新照片
|
||||
Terminals terminals = terminalPhotoService.getTakePicPhotoStatus(model).getData();
|
||||
if ( terminals.checkInclude() ) {
|
||||
String str = "装置:" + terminals.getCmdid() + " 在通道" + model.getChannelId() + "拍的最新图片已上传";
|
||||
webSocketServer.sendNotice(str);
|
||||
// System.out.println(str);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue