diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/ChannelAndTermDto.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/ChannelAndTermDto.java new file mode 100644 index 0000000..75f23c9 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/ChannelAndTermDto.java @@ -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; + + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/TermAndChannelLatestPhotoMapperDto.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/TermAndChannelLatestPhotoMapperDto.java new file mode 100644 index 0000000..240d949 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/TermAndChannelLatestPhotoMapperDto.java @@ -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; + + +} diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java index 282259a..6cc76f2 100644 --- a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java @@ -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 selectPhotos(); + List selectTermAndChannelLatestPhotoList(@Param("list") List list); + List selectPhotoListForOpen(@Param("termId") Integer terminalid,@Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime); diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java index e408f02..50d3643 100644 --- a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java @@ -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 selectAll(@Param("status") Integer status); + List selectChannelAndTermList(@Param("status") Integer status); + List selectTermAndLineList(@Param("status") Integer status); Terminals selectByCmdid(@Param("cmdid") String cmdid, @Param("status") Integer status); diff --git a/xymanager_dao/src/main/resources/mappers/LinesDao.xml b/xymanager_dao/src/main/resources/mappers/LinesDao.xml index f66fd93..924380d 100644 --- a/xymanager_dao/src/main/resources/mappers/LinesDao.xml +++ b/xymanager_dao/src/main/resources/mappers/LinesDao.xml @@ -23,7 +23,6 @@ id, name, bs_manufacturer, dy_level_id - + + + + + insert into terminals diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java index ab887bb..4b052a9 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java @@ -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 getPhotoBanner(PageVo vo) { TerminalPhotosModel model = new TerminalPhotosModel(); + int pageindex = vo.getPageindex(); int pagesize = vo.getPagesize(); PageUtils.SetPage(pageindex, pagesize); - List list = terminalPhotoDao.selectPhotos(); - boolean empty = CollectionUtil.isEmpty(list); - if (empty) { - model.setList(new ArrayList<>()); - } else { - List 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 list = terminalsDao.selectChannelAndTermList(CommonStatus.EFFECTIVE.value()); + + List termidlist = new ArrayList<>(); + for (ChannelAndTermDto item : list) { + Integer termid = item.getTermid(); + termidlist.add(termid); + } + + List lines = linesDao.selectLineByDyId(null, CommonStatus.EFFECTIVE.value()); + + List list2 = terminalPhotoDao.selectTermAndChannelLatestPhotoList(termidlist); + List 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 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 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 getLastedPhotoQueryParam(ReturnedPhotoParamsVo vo) {