图片轮询优化

master
liuguijing 2 years ago
parent 2ab7c240d5
commit 8d84c257cc

@ -16,6 +16,8 @@ public class TermChannelAndMapperDto {
private String channelname;
private String alias;
private Integer status;
private Integer maxResolutionWidth;

@ -25,5 +25,8 @@ public class LineAndGtAndChannelListModel implements Serializable {
@ApiModelProperty(value = "名称", example = "AAAA")
private String name;
@ApiModelProperty(value = "别名", example = "AAAA")
private String alias;
}
}

@ -26,6 +26,9 @@ public class TerminalChannelMapperListModel implements Serializable {
@ApiModelProperty(value = "装置编号", example = "123456")
private Integer termId;
@ApiModelProperty(value = "别名", example = "alias")
private String alias;
@ApiModelProperty(value = "通道编号", example = "123456")
private Integer channelid;

@ -37,6 +37,12 @@ public class TerminalPhotoListModel implements Serializable {
@ApiModelProperty(value = "通道编号", example = "123456")
private Integer channelId;
@ApiModelProperty(value = "通道名称", example = "123456")
private String channelName;
@ApiModelProperty(value = "别名", example = "123456")
private String alias;
@ApiModelProperty(value = "预置位编号", example = "123456")
private Integer presetId;

@ -52,6 +52,9 @@ public class TerminalPhotoSelectListModel implements Serializable {
@ApiModelProperty(value = "通道名称", example = "123456")
private String channnelname;
@ApiModelProperty(value = "别名", example = "123456")
private String alias;
@ApiModelProperty(value = "预置位编号", example = "123456")
private Integer presetId;

@ -47,6 +47,9 @@ public class TerminalPhotosModel implements Serializable {
@ApiModelProperty(value = "通道名称", example = "123456")
private String channnelname;
@ApiModelProperty(value = "别名", example = "123456")
private String alias;
@ApiModelProperty(value = "预置位编号", example = "123456")
private Integer presetId;

@ -20,6 +20,8 @@ public interface TerminalChannelMapperDao {
TerminalChannelMapper selectByPrimaryKey(Integer id);
List<TerminalChannelMapper> selectAll();
int updateByPrimaryKeySelective(TerminalChannelMapper record);
int updateByPrimaryKey(TerminalChannelMapper record);

@ -19,6 +19,11 @@
from terminal_channel_mapper
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_channel_mapper
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>

@ -14,6 +14,7 @@
<resultMap id="TerminalAndMapperMap" type="com.shxy.xymanager_common.dto.TermChannelAndMapperDto">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="termid" jdbcType="INTEGER" property="termid"/>
<result column="alias" jdbcType="VARCHAR" property="alias"/>
<result column="channel_id" jdbcType="INTEGER" property="channelid"/>
<result column="channel_name" jdbcType="VARCHAR" property="channelname"/>
<result column="max_resolution_width" jdbcType="INTEGER" property="maxResolutionWidth"/>
@ -93,6 +94,7 @@
select
x.id as id,
x.term_id as termid,
x.alias as alias,
x.channel_id as channel_id,
y.channel_name as channel_name,
y.max_resolution_width as max_resolution_width,

@ -11,9 +11,22 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="alarm_info" jdbcType="LONGVARCHAR" property="alarmInfo"/>
</resultMap>
<resultMap id="AlarmsAndDetailsMap" type="com.shxy.xymanager_common.entity.TerminalImgAlarms">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="term_id" jdbcType="INTEGER" property="termId"/>
<result column="channel_id" jdbcType="TINYINT" property="channelId"/>
<result column="preset_id" jdbcType="TINYINT" property="presetId"/>
<result column="photo_org_id" jdbcType="INTEGER" property="photoOrgId"/>
<result column="alarm_time" jdbcType="BIGINT" property="alarmTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="alarm_info" jdbcType="LONGVARCHAR" property="alarmInfo"/>
</resultMap>
<sql id="Base_Column_List">
id, term_id, channel_id, preset_id, photo_org_id,alarm_info, alarm_time, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
@ -21,14 +34,19 @@
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectAlarmsDetails" parameterType="java.lang.Long" resultMap="BaseResultMap">
<select id="selectAlarmsDetails" resultMap="AlarmsAndDetailsMap">
select
<include refid="Base_Column_List"/>
from terminal_img_alarms
a.term_id as termId,
a.channel_id as channelId,
a.preset_id as presetId,
a.photo_org_id as photoOrgId,
a.alarm_time as alarmTime,
a.term_id as termid,
from
terminal_img_alarms a left join terminal_img_alarm_details b on a.id = b.alarm_id
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from terminal_img_alarms
where id = #{id,jdbcType=BIGINT}

@ -2,13 +2,11 @@ package com.shxy.xymanager_service.cache;
import com.shxy.xymanager_common.dto.LineAndDyNameDto;
import com.shxy.xymanager_common.dto.TowerDto;
import com.shxy.xymanager_common.entity.TerminalChannelMapper;
import com.shxy.xymanager_common.entity.TerminalChannels;
import com.shxy.xymanager_common.entity.Terminals;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_dao.dao.LinesDao;
import com.shxy.xymanager_dao.dao.TerminalChannelsDao;
import com.shxy.xymanager_dao.dao.TerminalsDao;
import com.shxy.xymanager_dao.dao.TowerDao;
import com.shxy.xymanager_dao.dao.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -24,6 +22,8 @@ public class XyCache {
public static Map<Integer, Terminals> terminalMap = new HashMap<Integer, Terminals>();
public static Map<Integer, TowerDto> towerMap = new HashMap<Integer, TowerDto>();
public static Map<Integer, TerminalChannels> termchannelMap = new HashMap<Integer, TerminalChannels>();
/*装置编号+#+通道编号 装置映射表*/
public static Map<String, TerminalChannelMapper> termchannelMapMap = new HashMap<String, TerminalChannelMapper>();
@Autowired
private LinesDao linesDao;
@ -33,7 +33,8 @@ public class XyCache {
private TowerDao towerDao;
@Autowired
private TerminalChannelsDao terminalChannelsDao;
@Autowired
private TerminalChannelMapperDao terminalChannelMapperDao;
@PostConstruct
public void init() {
@ -58,6 +59,12 @@ public class XyCache {
termchannelMap.put(item.getId(), item);
}
List<TerminalChannelMapper> terminalChannelMapperlist = terminalChannelMapperDao.selectAll();
for (TerminalChannelMapper item : terminalChannelMapperlist) {
String s = item.getTermId() + "#" + item.getChannelId();
termchannelMapMap.put(s, item);
}
}
@PreDestroy

@ -183,10 +183,9 @@ public class LineServiceImpl implements LineService {
List<TermChannelAndMapperDto> list = terminalChannelsDao.selectByTermid(id, CommonStatus.EFFECTIVE.value());
for (TermChannelAndMapperDto item : list) {
LineAndGtAndChannelListModel.Bean bean = new LineAndGtAndChannelListModel.Bean();
Integer channelid = item.getChannelid();
String channelname = item.getChannelname();
bean.setId(channelid);
bean.setName(channelname);
bean.setId(item.getChannelid());
bean.setAlias(item.getAlias());
bean.setName(item.getChannelname());
beans.add(bean);
}
}

@ -90,8 +90,8 @@ public class OpenServiceImpl implements OpenService {
sysUserSession.setUserName(username);
sysUserSession.setRole(sysUser.getRole());
sysUserSession.setSessionId(sessionId);
BigInteger expiretime = MyDateUtils.TimeMillSecond2Second(MyDateUtils.offsetMinute(date, 30));
sysUserSession.setExpireTime(expiretime);
long expiretime = MyDateUtils.TimeMillSecond2Second(MyDateUtils.offsetMinute(date, 30));
sysUserSession.setExpireTime(BigInteger.valueOf(expiretime));
sysUserMapperDao.insertOrUpdate(sysUserSession, date, date);
jsonObject.set("errcode", 0);
jsonObject.set("errmsg", "OK");
@ -131,8 +131,8 @@ public class OpenServiceImpl implements OpenService {
return jsonObject;
} else {
BigInteger expireTime = sysUserSession.getExpireTime();
BigInteger currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
if (currentTime.subtract(expireTime).compareTo(time) > 0) {
long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
if ((currentTime - expireTime.longValue()) > time.longValue()) {
jsonObject.set("errcode", 1);
jsonObject.set("errmsg", "invalid session");
return jsonObject;
@ -189,8 +189,8 @@ public class OpenServiceImpl implements OpenService {
return jsonObject;
} else {
BigInteger expireTime = sysUserSession.getExpireTime();
BigInteger currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
if (currentTime.subtract(expireTime).compareTo(time) > 0) {
long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
if ((currentTime - expireTime.longValue()) > time.longValue()) {
jsonObject.set("errcode", 1);
jsonObject.set("errmsg", "invalid session");
return jsonObject;

@ -31,13 +31,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import sun.misc.Cache;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
*
@ -106,29 +102,36 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
model.setList(new ArrayList<>());
} else {
List<TerminalPhotoListModel.PhotoBean> beans = new ArrayList<>();
Map<Integer, TerminalChannels> termchannelMap = XyCache.termchannelMap;
Map<String, TerminalChannelMapper> termchannelMapMap = XyCache.termchannelMapMap;
for (TerminalPhoto item : list) {
TerminalPhotoListModel.PhotoBean photoBean = new TerminalPhotoListModel.PhotoBean();
photoBean.setChannelId(item.getChannelId());
photoBean.setFileSize(item.getFileSize());
photoBean.setHeight(item.getHeight());
photoBean.setMediaType(item.getMediaType());
if (item.getMediaType() == 0) {
photoBean.setPath(photoaddress + item.getPath());
} else {
photoBean.setPath(videoaddress + item.getPath());
if (StringUtils.isNotBlank(item.getThumb())) {
photoBean.setThumb(videoaddress + item.getThumb());
Integer mediaType = item.getMediaType();
if (mediaType == 0 && mediaType == 1) {
TerminalPhotoListModel.PhotoBean photoBean = new TerminalPhotoListModel.PhotoBean();
photoBean.setChannelId(item.getChannelId());
photoBean.setFileSize(item.getFileSize());
photoBean.setHeight(item.getHeight());
photoBean.setMediaType(item.getMediaType());
if (mediaType == 0) {
photoBean.setPath(photoaddress + item.getPath());
} else {
photoBean.setPath(videoaddress + item.getPath());
if (StringUtils.isNotBlank(item.getThumb())) {
photoBean.setThumb(videoaddress + item.getThumb());
}
}
photoBean.setChannelName(termchannelMap.get(item.getChannelId()).getChannelName());
photoBean.setAlias(termchannelMapMap.get(item.getTermId() + "#" + item.getChannelId()).getAlias());
photoBean.setId(item.getId());
photoBean.setTermId(item.getTermId());
photoBean.setWidth(item.getWidth());
photoBean.setPresetId(item.getPresetId());
long phototime = MyDateUtils.TimeSecond2MillSecond(item.getPhotoTime().longValue());
photoBean.setPhotoTime(MyDateUtils.date(phototime));
long rectime = MyDateUtils.TimeSecond2MillSecond(item.getRecvTime().longValue());
photoBean.setRecvTime(MyDateUtils.date(rectime));
beans.add(photoBean);
}
photoBean.setId(item.getId());
photoBean.setTermId(item.getTermId());
photoBean.setWidth(item.getWidth());
photoBean.setPresetId(item.getPresetId());
long phototime = MyDateUtils.TimeSecond2MillSecond(item.getPhotoTime().longValue());
photoBean.setPhotoTime(MyDateUtils.date(phototime));
long rectime = MyDateUtils.TimeSecond2MillSecond(item.getRecvTime().longValue());
photoBean.setRecvTime(MyDateUtils.date(rectime));
beans.add(photoBean);
}
model.setList(beans);
}
@ -160,8 +163,6 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
} else {
List<Integer> termidlist = new ArrayList<>();
ArrayList<Integer> channelidlist = new ArrayList<>();
ArrayList<Integer> lineidlist = new ArrayList<>();
ArrayList<Integer> toweridlist = new ArrayList<>();
List<DyAndLineAndTowerAndTermDto> dtos = new ArrayList<>();
if (dyid == null || dyid.intValue() == 0) {
@ -210,6 +211,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
Map<Integer, Terminals> terminalMap = XyCache.terminalMap;
Map<Integer, LineAndDyNameDto> lineMap = XyCache.lineMap;
Map<Integer, TerminalChannels> termchannelMap = XyCache.termchannelMap;
Map<String, TerminalChannelMapper> termchannelMapMap = XyCache.termchannelMapMap;
for (TerminalPhoto item : list) {
TerminalPhotoSelectListModel.PhotoBean photoBean = new TerminalPhotoSelectListModel.PhotoBean();
photoBean.setTermid(item.getTermId());
@ -221,6 +223,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
photoBean.setChannelid(item.getChannelId());
photoBean.setCmdid(terminals.getCmdid());
photoBean.setChannnelname(termchannelMap.get(item.getChannelId()).getChannelName());
photoBean.setAlias(termchannelMapMap.get(item.getTermId() + "#" + item.getChannelId()).getAlias());
photoBean.setMediaType(item.getMediaType());
photoBean.setOrginalid(item.getOrginalId());
if (item.getMediaType() == 0) {
@ -380,46 +383,73 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
List<TerminalPhotosModel.PhotosBean> beans = new ArrayList<>();
if (!CollectionUtil.isEmpty(list)) {
Map<Integer, LineAndDyNameDto> lineMap = XyCache.lineMap;
Map<Integer, Terminals> terminalMap = XyCache.terminalMap;
Map<Integer, TerminalChannels> termchannelMap = XyCache.termchannelMap;
Map<String, TerminalChannelMapper> termchannelMapMap = XyCache.termchannelMapMap;
List<Integer> termidlist = new ArrayList<>();
for (ChannelAndTermDto item : list) {
Integer termid = item.getTermid();
termidlist.add(termid);
}
List<TermAndChannelLatestPhotoMapperDto> list2 = terminalPhotoDao.selectTermAndChannelLatestPhotoList(termidlist);
for (ChannelAndTermDto item : list) {
TerminalPhotosModel.PhotosBean photosBean = new TerminalPhotosModel.PhotosBean();
photosBean.setTermid(item.getTermid());
photosBean.setLineid(item.getLineid());
photosBean.setChannnelname(item.getChannelname());
photosBean.setChannelid(item.getChannelid());
photosBean.setDisplayname(item.getDisplayname());
LineAndDyNameDto lineAndDyNameDto = XyCache.lineMap.get(item.getLineid());
photosBean.setLinename(lineAndDyNameDto.getName());
for (int y = 0; y < list2.size(); y++) {
TermAndChannelLatestPhotoMapperDto item2 = list2.get(y);
if (item.getTermid().intValue() == item2.getTermid().intValue() && item.getChannelid().intValue() == item2.getChannelid().intValue()) {
photosBean.setPath(item2.getPath());
long recvtime = MyDateUtils.TimeSecond2MillSecond(item2.getRecvTime().longValue());
photosBean.setRecvTime(MyDateUtils.date(recvtime));
long phototime = MyDateUtils.TimeSecond2MillSecond(item2.getPhotoTime().longValue());
photosBean.setPhotoTime(MyDateUtils.date(phototime));
photosBean.setMediatype(item2.getMediatype());
if (item2.getMediatype().intValue() == 0) {
photosBean.setPath(photoaddress + item2.getPath());
for (int y = 0; y < list2.size(); y++) {
log.info("日志开始");
TermAndChannelLatestPhotoMapperDto item = list2.get(y);
Integer mediatype = item.getMediatype();
if (mediatype == 0 || mediatype == 1) {
Integer termid = item.getTermid();
Integer lineid = terminalMap.get(termid).getLineid();
LineAndDyNameDto lineAndDyNameDto = lineMap.get(lineid);
Integer channelid = item.getChannelid();
TerminalPhotosModel.PhotosBean photosBean = new TerminalPhotosModel.PhotosBean();
photosBean.setTermid(termid);
photosBean.setLineid(lineid);
if (lineAndDyNameDto != null) {
photosBean.setChannnelname(termchannelMap.get(channelid).getChannelName());
photosBean.setLinename(lineAndDyNameDto.getName());
} else {
photosBean.setChannnelname("");
photosBean.setLinename("");
}
photosBean.setChannelid(channelid);
Terminals terminals = terminalMap.get(termid);
if (terminals != null) {
photosBean.setDisplayname(terminals.getDisplayName());
} else {
photosBean.setDisplayname("");
}
if (termchannelMapMap != null) {
TerminalChannelMapper terminalChannelMapper = termchannelMapMap.get(termid + "#" + channelid);
if (terminalChannelMapper != null) {
photosBean.setAlias(terminalChannelMapper.getAlias());
} else {
photosBean.setPath(videoaddress + item2.getPath());
photosBean.setAlias("");
}
photosBean.setOrginalid(item2.getOrginalid());
photosBean.setPresetId(item2.getPresetId());
break;
} else {
photosBean.setAlias("");
}
photosBean.setPath(item.getPath());
long recvtime = MyDateUtils.TimeSecond2MillSecond(item.getRecvTime().longValue());
photosBean.setRecvTime(MyDateUtils.date(recvtime));
long phototime = MyDateUtils.TimeSecond2MillSecond(item.getPhotoTime().longValue());
photosBean.setPhotoTime(MyDateUtils.date(phototime));
photosBean.setMediatype(mediatype);
if (mediatype.intValue() == 0) {
photosBean.setPath(photoaddress + item.getPath());
} else {
photosBean.setPath(videoaddress + item.getPath());
}
photosBean.setOrginalid(item.getOrginalid());
photosBean.setPresetId(item.getPresetId());
beans.add(photosBean);
}
beans.add(photosBean);
}
}
model.setList(beans);
PageInfo pageData = PageUtils.getPageData(list);
int currentpage = pageData.getPageNum();

Loading…
Cancel
Save