Revert "feat:主动拍照增加定时任务推送通知"

This reverts commit 9e5f283984.
hunan
郭承 9 months ago
parent 9e5f283984
commit c30c5291bf

@ -1,28 +0,0 @@
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;
}

@ -1,34 +0,0 @@
package com.shxy.xymanager_common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@ApiModel(value = "装置控制对象", description = "装置控制对象描述")
public class TermCtrlVo {
@ApiModelProperty(value = "装置编号", example = "123455")
private Integer termId;
@ApiModelProperty(value = "通道编号", example = "123456")
private Integer channelId;
@NotNull(message = "不能传入空值")
@ApiModelProperty(value = "控制对象数组", required = true)
private List<CtrlBean> list;
@Data
public static class CtrlBean {
@ApiModelProperty(value = "命令key", example = "act")
private String name;
@ApiModelProperty(value = "命令value", example = "shecdule")
private String value;
}
}

@ -32,7 +32,4 @@ public interface TerminalChannelMapperDao {
int updateByPrimaryKeySelective(TerminalChannelMapper record); int updateByPrimaryKeySelective(TerminalChannelMapper record);
int updateByPrimaryKey(TerminalChannelMapper record); int updateByPrimaryKey(TerminalChannelMapper record);
TerminalChannelMapper selectByTermIdAndChannelId(@Param("termId") Integer termId, @Param("channelId") Integer channelId);
} }

@ -162,12 +162,4 @@
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="selectByTermIdAndChannelId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_channel_mapper
where term_id = #{termId} and channel_id = #{channelId}
</select>
</mapper> </mapper>

@ -1,67 +0,0 @@
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();
}
}
}
}
}
}

@ -10,20 +10,17 @@ import com.shxy.xymanager_common.constant.Constants;
import com.shxy.xymanager_common.dto.PhotoTimeResultDto; import com.shxy.xymanager_common.dto.PhotoTimeResultDto;
import com.shxy.xymanager_common.entity.RequestResults; import com.shxy.xymanager_common.entity.RequestResults;
import com.shxy.xymanager_common.entity.Resolution; import com.shxy.xymanager_common.entity.Resolution;
import com.shxy.xymanager_common.entity.TerminalChannelMapper;
import com.shxy.xymanager_common.entity.Terminals; import com.shxy.xymanager_common.entity.Terminals;
import com.shxy.xymanager_common.enums.CommonStatus; import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts; import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.ResolutionModel; import com.shxy.xymanager_common.model.ResolutionModel;
import com.shxy.xymanager_common.model.TerminalScheduleRuleTimeListModel; import com.shxy.xymanager_common.model.TerminalScheduleRuleTimeListModel;
import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.util.CmaUtil; import com.shxy.xymanager_common.util.CmaUtil;
import com.shxy.xymanager_common.util.MyDateUtils; import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.StringUtils; import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_common.util.xinyin.ProcessExecUtils; import com.shxy.xymanager_common.util.xinyin.ProcessExecUtils;
import com.shxy.xymanager_common.vo.*; import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.RequestResultsDao; import com.shxy.xymanager_dao.dao.RequestResultsDao;
import com.shxy.xymanager_dao.dao.TerminalChannelMapperDao;
import com.shxy.xymanager_dao.dao.TerminalResolutionDao; import com.shxy.xymanager_dao.dao.TerminalResolutionDao;
import com.shxy.xymanager_service.service.CacheService; import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.TermSetService; import com.shxy.xymanager_service.service.TermSetService;
@ -33,7 +30,6 @@ import org.springframework.stereotype.Service;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -56,12 +52,6 @@ public class TermSetServiceImpl implements TermSetService {
@Autowired @Autowired
private RequestResultsDao requestResultsDao; private RequestResultsDao requestResultsDao;
@Autowired
TerminalChannelMapperDao terminalChannelMapperDao;
//记录主动拍照参数
public static Map<String , TermChannelModel> termChannelModelMap = new HashMap<>();
@Override @Override
public ServiceBody<String> alarmMark(VoiceCtrlVo vo) { public ServiceBody<String> alarmMark(VoiceCtrlVo vo) {
String cmd = CmaUtil.alarmMark(vo.getCmdId(), vo.getCtrl()); String cmd = CmaUtil.alarmMark(vo.getCmdId(), vo.getCtrl());
@ -84,93 +74,5 @@ public class TermSetServiceImpl implements TermSetService {
return Asserts.success(model); return Asserts.success(model);
} }
/**
*
*
* @param vo
* @return
*/
@Override
public ServiceBody<CmaRequestModel> updateTermCamera(UpdateCameraVo vo) {
CmaRequestModel model = new CmaRequestModel();
Integer termId = vo.getTermId();
Integer channelId = vo.getChannelId();
Integer type = vo.getType();
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap();
Terminals terminals = terminalMap.get(termId);
String cmdid = null;
if (terminals != null) {
cmdid = terminals.getCmdid();
}
int requestId = Constants.REQUEST_ID.addAndGet(1);
String cmd = CmaUtil.cameractrl(cmdid, channelId, requestId, type);
ProcessExecUtils.exec(cmd);
model.setRequestId(requestId);
return Asserts.success(model);
}
/**
*
*
* @param vo
* @return
*/
@Override
public ServiceBody<CmaRequestModel> setTermCamera(TermCtrlVo vo) {
//返回对象
CmaRequestModel model = new CmaRequestModel();
//装置信息
List<TermCtrlVo.CtrlBean> list = vo.getList();
//装置id
Integer termId = vo.getTermId();
//通道id
Integer channelId = vo.getChannelId();
//获取当前系统时间
Long currentTime = System.currentTimeMillis();
//根据当前的装置id和通道id查询当前最新的图片时间
TerminalChannelMapper terminalChannelMapper = terminalChannelMapperDao.selectByTermIdAndChannelId(termId, channelId);
Long photoTime = terminalChannelMapper.getPhotoTime().longValue();
termChannelModelMap.put(termId + "_" + channelId, new TermChannelModel(termId, channelId, photoTime, currentTime));
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap();
Terminals terminals = terminalMap.get(termId);
String cmdid = null;
if (terminals != null) {
cmdid = terminals.getCmdid();
}
int requestId = Constants.REQUEST_ID.addAndGet(1);
List<String> cmd = CmaUtil.cmaCtrl(list, cmdid, requestId);
ProcessExecUtils.execArray(cmd);
model.setRequestId(requestId);
DateTime now = DateTime.now();
model.setDate(now);
return Asserts.success(model);
}
@Override
public ServiceBody<CmaRequestBackModel> getTermCameraRequest(RequestIdVo vo) {
CmaRequestBackModel model = new CmaRequestBackModel();
RequestResults results = requestResultsDao.selectByRequestId(vo.getRequestid());
if (null != results) {
model.setSuccess(CommonStatus.EFFECTIVE.value());
model.setId(results.getId());
model.setTermId(results.getTermId());
model.setRequestType(results.getRequestType());
model.setRequestId(results.getRequestId());
model.setClientId(results.getClientId());
model.setRequestTime(results.getRequestTime());
model.setData(results.getData());
model.setFrameNo(results.getFrameNo());
model.setScheduleStatus(results.getScheduleStatus());
model.setResult(results.getResult());
} else {
model.setSuccess(CommonStatus.DELETE.value());
}
return Asserts.success(model);
}
} }

@ -713,119 +713,4 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
} }
} }
@Override
public ServiceBody<String> uploadPhoto(MultipartFile file, Integer termid, String cmdid, Integer channel, BigInteger phototime) throws IOException {
DateTime date = MyDateUtils.date(phototime.longValue());
int year = date.year();
String mon = "";
int month = date.monthBaseOne();
if (month < 10) {
mon = "0" + month;
}
String daystr = "";
int day = date.dayOfMonth();
if (day < 10) {
daystr = "0" + day;
}
String sub = StrUtil.sub(cmdid, cmdid.length() - 2, cmdid.length());
String location = C_PATH + year + "/" + mon + "/" + daystr + "/" + sub;
File saveFile = new File(location);
if (!saveFile.exists()) {
boolean mkdirs = saveFile.mkdirs();
System.out.println("日期文件夹" + (mkdirs ? "创建成功" : "创建失败"));
}
File file1 = new File(saveFile.getAbsoluteFile() + "/" + file.getOriginalFilename());
file.transferTo(file1);
TerminalPhoto record = new TerminalPhoto();
record.setTermId(termid);
record.setPhotoTime((BigInteger.valueOf(MyDateUtils.TimeMillSecond2Second(date))));
record.setChannelId(channel);
record.setOrginalId(BigInteger.valueOf(RandomUtil.randomLong()));
record.setPath(year + "/" + mon + "/" + daystr + "/" + sub + "/" + file.getOriginalFilename());
record.setRecvTime(BigInteger.valueOf(MyDateUtils.TimeMillSecond2Second(date)));
record.setCreateTime(new Date());
record.setChannelId(channel);
record.setMediaType(0);
record.setPresetId(255);
int i = terminalPhotoDao.insertSelective(record);
if (i != 0) {
return Asserts.success("上传成功");
} else {
return Asserts.error("上传失败");
}
}
@Override
public PhotoDayModel getDayModel(Integer termid, Integer channelId, Long start, Long end) {
TerminalPhotoExample example = new TerminalPhotoExample();
TerminalPhotoExample.Criteria criteria = example.createCriteria();
criteria.andTermIdEqualTo(termid);
if (start != null) {
criteria.andPhotoTimeGreaterThanOrEqualTo(start);
}
if (end != null) {
criteria.andPhotoTimeLessThan(end);
}
if (channelId != null) {
criteria.andChannelIdEqualTo(channelId);
}
long count = terminalPhotoDao.countByExample(example);
PhotoDayModel result = new PhotoDayModel();
result.setPhotoCount(count);
if (count > 0) {
example.setOrderByClause("photo_time desc");
PageHelper.startPage(1, 1);
List<TerminalPhoto> list = terminalPhotoDao.selectByExample(example);
TerminalPhoto last = list.get(0);
long lastrecv = last.getRecvTime().longValue();
result.setLastRecvTime(new Date(lastrecv * 1000));
long lastphoto = last.getPhotoTime().longValue();
result.setLastPhotoTime(new Date(lastphoto * 1000));
result.setLastChannelId(last.getChannelId());
result.setLastPhotoPath(photoAddress + last.getPath());
example.setOrderByClause("photo_time asc");
PageHelper.startPage(1, 1);
list = terminalPhotoDao.selectByExample(example);
TerminalPhoto first = list.get(0);
long firstrecv = first.getRecvTime().longValue();
result.setFirstRecvTime(new Date(firstrecv * 1000));
long firstphoto = first.getPhotoTime().longValue();
result.setFirstPhotoTime(new Date(firstphoto * 1000));
result.setFirstChannelId(first.getChannelId());
result.setFirstPhotoPath(photoAddress + first.getPath());
long totalDays = DateUtil.getDifferenceInDays(result.getFirstPhotoTime(), result.getLastPhotoTime());
result.setTotalDays(totalDays);
}
return result;
}
@Override
public ServiceBody<Terminals> getTakePicPhotoStatus(TermChannelModel model) {
Boolean hasNew = false;
Integer termId = model.getTermId();
Integer channelId = model.getChannelId();
Long photoTime = model.getPhotoTime();
if ( null == photoTime ) {
Asserts.fail("查询时间不能缺少");
}
TerminalChannelMapper mapper = terminalChannelMapperDao.selectByTermIdAndChannelId(termId, channelId);
Map<Integer, Terminals> terminalMap = newCacheService.getTerminalMap();
Terminals terminals = terminalMap.get(termId);
if ( null != mapper ) {
if (mapper.getPhotoTime().longValue() > photoTime) {
hasNew = true;
}
}
terminals.setChecked(hasNew);
return Asserts.success(terminals);
}
} }

@ -1,12 +1,10 @@
package com.shxy.xymanager_service.service; package com.shxy.xymanager_service.service;
import com.shxy.xymanager_common.bean.ServiceBody; import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.entity.Terminals;
import com.shxy.xymanager_common.model.*; import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.vo.*; import com.shxy.xymanager_common.vo.*;
import java.util.Date; import java.util.Date;
import java.util.Map;
/** /**
* *
@ -95,30 +93,4 @@ public interface TerminalPhotoService {
* @return * @return
*/ */
ServiceBody<String> deletePicList(DeletePicVo vo); ServiceBody<String> deletePicList(DeletePicVo vo);
/**
*
* @param file
* @param termid
* @param cmdid
* @param phototime
* @return
*/
ServiceBody<String> uploadPhoto(MultipartFile file, Integer termid, String cmdid, Integer channel, BigInteger phototime) throws IOException;
PhotoDayModel getDayModel(Integer termid, Integer channelId, Long start, Long end);
ServiceBody<TerminalPhotoListModel> getTestTerminalPhotoList(String requestIp);
ServiceBody<String> takeAlarm(TerminalPhotoTestVo vo);
/**
*
* @param model
* @return
*/
ServiceBody<Terminals> getTakePicPhotoStatus(TermChannelModel model);
} }

Loading…
Cancel
Save