图片轮询修改和图片轮询查询优化

jni
liuguijing 2 years ago
parent 70ee1b191c
commit 9e8be5fcc6

@ -0,0 +1,21 @@
package com.shxy.xymanager_common.dto;
import lombok.Data;
import java.util.List;
/**
*
*/
@Data
public class ChannelAndTermDto {
private Integer termid;
private Integer lineid;
private String cmdid;
private Integer channelid;
private String channelname;
private String displayname;
}

@ -0,0 +1,29 @@
package com.shxy.xymanager_common.dto;
import lombok.Data;
import java.math.BigInteger;
@Data
public class TermAndChannelLatestPhotoMapperDto {
private BigInteger id;
private Integer termid;
private Integer channelid;
private Integer presetId;
private BigInteger orginalid;
private Integer mediatype;
private BigInteger photoTime;
private BigInteger recvTime;
private String path;
}

@ -2,6 +2,7 @@ package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.dto.PhotoAndLineAndChannelDto;
import com.shxy.xymanager_common.dto.PhotoParamsDto;
import com.shxy.xymanager_common.dto.TermAndChannelLatestPhotoMapperDto;
import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto;
import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.vo.PhotoParamsVo;
@ -35,6 +36,8 @@ public interface TerminalPhotoDao {
List<PhotoAndLineAndChannelDto> selectPhotos();
List<TermAndChannelLatestPhotoMapperDto> selectTermAndChannelLatestPhotoList(@Param("list") List<Integer> list);
List<TerminalPhoto> selectPhotoListForOpen(@Param("termId") Integer terminalid,@Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime);

@ -1,5 +1,6 @@
package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.dto.ChannelAndTermDto;
import com.shxy.xymanager_common.dto.TerminalInfoDto;
import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto;
import com.shxy.xymanager_common.entity.Terminals;
@ -14,6 +15,8 @@ public interface TerminalsDao {
List<Terminals> selectAll(@Param("status") Integer status);
List<ChannelAndTermDto> selectChannelAndTermList(@Param("status") Integer status);
List<TerminalsAndLineAndChannelDto> selectTermAndLineList(@Param("status") Integer status);
Terminals selectByCmdid(@Param("cmdid") String cmdid, @Param("status") Integer status);

@ -23,7 +23,6 @@
<sql id="Base_Column_List">
id, name, bs_manufacturer, dy_level_id
</sql>
<select id="selectAll" resultMap="LineAndDyNameMap">
select
x.id as id,

@ -33,6 +33,18 @@
<result column="path" jdbcType="VARCHAR" property="path"/>
<result column="media_type" jdbcType="VARCHAR" property="mediatype"/>
</resultMap>
<resultMap id="TermAndChannelLatestPhotoMap" type="com.shxy.xymanager_common.dto.TermAndChannelLatestPhotoMapperDto">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="term_id" jdbcType="INTEGER" property="termid"/>
<result column="channel_id" jdbcType="INTEGER" property="channelid"/>
<result column="preset_id" jdbcType="INTEGER" property="presetId"/>
<result column="orginal_id" jdbcType="BIGINT" property="orginalid"/>
<result column="media_type" jdbcType="INTEGER" property="mediatype"/>
<result column="photo_time" jdbcType="BIGINT" property="photoTime"/>
<result column="recv_time" jdbcType="BIGINT" property="recvTime"/>
<result column="path" jdbcType="VARCHAR" property="path"/>
</resultMap>
<sql id="Base_Column_List">
id, term_id, channel_id,orginal_id, media_type,preset_id, width, height, file_size, photo_time, recv_time,
path, thumb,create_time
@ -68,7 +80,6 @@
d.channel_name as channel_name,
a.preset_id as preset_id,
a.orginal_id as orginal_id,
a.media_type as media_type,
a.photo_time as photo_time,
a.recv_time as recv_time,
a.path as path,
@ -79,6 +90,31 @@
join `lines` c on b.line_id = c.id)
join terminal_channels d on a.channel_id = d.id)
order by photo_time desc
</select>
<select id="selectTermAndChannelLatestPhotoList" resultMap="TermAndChannelLatestPhotoMap">
SELECT
a.id as id,
a.term_id as term_id,
a.channel_id as channel_id,
a.path as path,
a.preset_id as preset_id,
a.orginal_id as orginal_id,
a.photo_time as photo_time,
a.recv_time as recv_time,
a.media_type as media_type
FROM terminal_photos a
JOIN (SELECT max(id) AS id FROM terminal_photos WHERE term_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY term_id , channel_id) b ON a.id = b.id
WHERE term_id in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
GROUP BY term_id , channel_id
</select>
<select id="getLatestPhoto" resultType="java.math.BigInteger">

@ -46,6 +46,15 @@
</collection>
</resultMap>
<resultMap id="ChannelAndTerm" type="com.shxy.xymanager_common.dto.ChannelAndTermDto">
<id column="term_id" jdbcType="INTEGER" property="termid"/>
<result column="line_id" jdbcType="INTEGER" property="lineid"/>
<result column="cmdid" jdbcType="VARCHAR" property="cmdid"/>
<result column="channel_id" jdbcType="INTEGER" property="channelid"/>
<result column="channel_name" jdbcType="VARCHAR" property="channelname"/>
<result column="display_name" jdbcType="VARCHAR" property="displayname"/>
</resultMap>
<sql id="Base_Column_List">
id, line_id,tower_id,cmdid, org_id, equip_name, display_name, model, essential_info_version, has_pan,
bs_manufacturer, bs_production_date, bs_identifier, latitude, longitude, create_time,
@ -59,6 +68,20 @@
where status = #{status}
</select>
<select id="selectChannelAndTermList" resultMap="ChannelAndTerm">
select
a.id as term_id,
a.line_id as line_id,
a.cmdid as cmdid,
a.display_name as display_name,
b.channel_id as channel_id,
c.channel_name as channel_name
from ((terminals a left join
terminal_channel_mapper b on a.id = b.term_id) left join
terminal_channels c on b.channel_id = c.id)
where a.status = #{status}
</select>
<select id="selectTermAndLineList" resultMap="LineAndGtAndTermMap">
select
a.id as id,
@ -105,6 +128,7 @@
from terminals
where line_id = #{lineid} and tower_id = #{towerid} and status = #{status} limit 1;
</select>
<insert id="insertSelective" parameterType="com.shxy.xymanager_common.entity.Terminals">
insert into terminals
<trim prefix="(" suffix=")" suffixOverrides=",">

@ -13,10 +13,7 @@ import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.constant.Constants;
import com.shxy.xymanager_common.dto.PhotoAndLineAndChannelDto;
import com.shxy.xymanager_common.dto.PhotoParamsDto;
import com.shxy.xymanager_common.dto.PhotoTimeResultDto;
import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto;
import com.shxy.xymanager_common.dto.*;
import com.shxy.xymanager_common.entity.Lines;
import com.shxy.xymanager_common.entity.TerminalChannels;
import com.shxy.xymanager_common.entity.TerminalPhoto;
@ -313,40 +310,58 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Override
public ServiceBody<TerminalPhotosModel> getPhotoBanner(PageVo vo) {
TerminalPhotosModel model = new TerminalPhotosModel();
int pageindex = vo.getPageindex();
int pagesize = vo.getPagesize();
PageUtils.SetPage(pageindex, pagesize);
List<PhotoAndLineAndChannelDto> list = terminalPhotoDao.selectPhotos();
boolean empty = CollectionUtil.isEmpty(list);
if (empty) {
model.setList(new ArrayList<>());
} else {
List<TerminalPhotosModel.PhotosBean> beans = new ArrayList<>();
for (PhotoAndLineAndChannelDto item : list) {
TerminalPhotosModel.PhotosBean photoBean = new TerminalPhotosModel.PhotosBean();
photoBean.setTermid(item.getTermid());
photoBean.setDisplayname(item.getDisplayname());
photoBean.setLineid(item.getLineid());
photoBean.setLinename(item.getLinename());
photoBean.setChannelid(item.getChannelid());
photoBean.setChannnelname(item.getChannnelname());
photoBean.setOrginalid(item.getOrginalid());
photoBean.setMediatype(item.getMediatype());
photoBean.setPresetId(item.getPresetId());
photoBean.setPath(photoaddress + item.getPath());
if (item.getMediatype() == 0) {
photoBean.setPath(photoaddress + item.getPath());
} else {
photoBean.setPath(videoaddress + item.getPath());
List<ChannelAndTermDto> list = terminalsDao.selectChannelAndTermList(CommonStatus.EFFECTIVE.value());
List<Integer> termidlist = new ArrayList<>();
for (ChannelAndTermDto item : list) {
Integer termid = item.getTermid();
termidlist.add(termid);
}
List<Lines> lines = linesDao.selectLineByDyId(null, CommonStatus.EFFECTIVE.value());
List<TermAndChannelLatestPhotoMapperDto> list2 = terminalPhotoDao.selectTermAndChannelLatestPhotoList(termidlist);
List<TerminalPhotosModel.PhotosBean> beans = new ArrayList<>();
for (ChannelAndTermDto item : list) {
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()) {
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());
photosBean.setPath(item2.getPath());
BigInteger recvtime = MyDateUtils.TimeSecond2MillSecond(item2.getRecvTime().longValue());
photosBean.setRecvTime(MyDateUtils.date(recvtime.longValue()));
BigInteger phototime = MyDateUtils.TimeSecond2MillSecond(item2.getPhotoTime().longValue());
photosBean.setPhotoTime(MyDateUtils.date(phototime.longValue()));
photosBean.setMediatype(item2.getMediatype());
photosBean.setOrginalid(item2.getOrginalid());
photosBean.setPresetId(item2.getPresetId());
for (int z = 0; z < lines.size(); z++) {
Lines lines1 = lines.get(z);
if (item.getLineid() == lines1.getId()) {
photosBean.setLinename(lines1.getName());
break;
}
}
beans.add(photosBean);
break;
}
BigInteger phototime = MyDateUtils.TimeSecond2MillSecond(item.getPhotoTime().longValue());
photoBean.setPhotoTime(MyDateUtils.date(phototime.longValue()));
BigInteger rectime = MyDateUtils.TimeSecond2MillSecond(item.getRecvTime().longValue());
photoBean.setRecvTime(MyDateUtils.date(rectime.longValue()));
beans.add(photoBean);
}
model.setList(beans);
}
model.setList(beans);
PageInfo pageData = PageUtils.getPageData(list);
int currentpage = pageData.getPageNum();
model.setCurrentpage(currentpage);
@ -357,7 +372,11 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
model.setPagesize(pageSize);
int pages = pageData.getPages();
model.setTotalpage(pages);
return Asserts.success(model);
}
@Override
@ -397,7 +416,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Override
public ServiceBody<TerminalStatusGetModel> getPhotoQueryParam(ReturnedPhotoParamsGetVo vo) {
TerminalStatusGetModel model = new TerminalStatusGetModel();
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=imgparams --cmdid="+vo.getCmdId() +"\t" +"--clientid=10 --reqid="+Constants.REQUEST_ID+"\t" +"--flag=0 --rf=7 --channel=" + vo.getChannelId();
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=imgparams --cmdid=" + vo.getCmdId() + "\t" + "--clientid=10 --reqid=" + Constants.REQUEST_ID + "\t" + "--flag=0 --rf=7 --channel=" + vo.getChannelId();
ProcessExecUtils.exec(cmd);
model.setRequestId(Constants.REQUEST_ID.addAndGet(1));
/* TerminalPhotosParamsModel model = new TerminalPhotosParamsModel();
@ -411,10 +430,10 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Override
public ServiceBody<Integer> addOrUpdatePhotoParams(PhotoParamsVo vo) {
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=imgparams --clientid=10 --cmdid=" + vo.getCmdId() + "\t" + "--color=" + vo.getColor() + "\t" + "--resolution=" + vo.getResolution() + "\t"
+ "--luminance=" + vo.getLuminance() + "\t" + "-contrast=" + vo.getContrast() + "\t" + "--saturation=" + vo.getSaturation() + "\t" + "--channel=" + vo.getChannelId();
+ "--luminance=" + vo.getLuminance() + "\t" + "-contrast=" + vo.getContrast() + "\t" + "--saturation=" + vo.getSaturation() + "\t" + "--channel=" + vo.getChannelId();
ProcessExecUtils.exec(cmd);
return Asserts.success(Constants.REQUEST_ID.addAndGet(1));
}
}
@Override
public ServiceBody<TerminalPhotosParamsModel> getLastedPhotoQueryParam(ReturnedPhotoParamsVo vo) {

Loading…
Cancel
Save