修复告警查询的bug优化首页的线路查询

master
liuguijing 2 years ago
parent 30fb709e85
commit 49402df618

@ -0,0 +1,18 @@
package com.shxy.xymanager_common.dto;
import lombok.Data;
import java.util.List;
/**
*
*/
@Data
public class TermAndChannelDto {
private Integer termid;
private List<TermChannelAndMapperDto> channellist;
}

@ -8,17 +8,13 @@ import java.util.Date;
import java.util.List;
@Data
public class TerminalsAndLineAndChannelDto implements Serializable {
public class TerminalsAndStatusDto implements Serializable {
private Integer id;
private Integer lineid;
private String linename;
private Integer towerid;
private String towername;
private String cmdid;
private Short orgId;
@ -43,16 +39,6 @@ public class TerminalsAndLineAndChannelDto implements Serializable {
private Double longitude;
private Integer markId;
private Integer width;
private Integer height;
private String color;
private Short boderWidth;
private Short signalStrength4g;
private BigInteger bootTime;
@ -63,8 +49,6 @@ public class TerminalsAndLineAndChannelDto implements Serializable {
private BigInteger lastHeartbeat;
private List<TerminalChannelsDto> list;
private static final long serialVersionUID = 1L;
}

@ -22,6 +22,7 @@ public class HeaderUtil {
public void setAddress(String address) {
HeaderUtil.address = address;
}
/**
*
*
@ -43,7 +44,11 @@ public class HeaderUtil {
requestip = protocol.concat("://").concat(host).concat(":").concat(String.valueOf(port));
}
} else {
requestip = origin;
if (origin.contains("localhost")) {
requestip = address;
} else {
requestip = origin;
}
}
return requestip;
}

@ -1,6 +1,7 @@
package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.dto.DyLineAndTerminalAndChannelDto;
import com.shxy.xymanager_common.dto.TermAndChannelDto;
import com.shxy.xymanager_common.dto.TermChannelAndMapperDto;
import com.shxy.xymanager_common.entity.TerminalChannels;
import com.shxy.xymanager_common.vo.TerminalChannelVo;
@ -11,6 +12,7 @@ import java.util.Date;
import java.util.List;
public interface TerminalChannelsDao {
int deleteByPrimaryKey(Integer id);
int insertList(@Param("list") List<TerminalChannels> record,@Param("status") Integer status, @Param("createat") Date create, @Param("updateat") Date update);
@ -19,6 +21,8 @@ public interface TerminalChannelsDao {
List<TerminalChannels> selectAllChannelList();
List<TermAndChannelDto> selectTermChannelList(@Param("status") Integer status);
List<TermChannelAndMapperDto> selectChannelByTowerId(@Param("towerid") Integer towerid, @Param("status") Integer status);
List<TermChannelAndMapperDto> selectByTermid(@Param("termid") Integer termid, @Param("status") Integer status);

@ -2,7 +2,7 @@ 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.dto.TerminalsAndStatusDto;
import com.shxy.xymanager_common.entity.Terminals;
import com.shxy.xymanager_common.vo.RelateTerminalListRuleIdVo;
import com.shxy.xymanager_common.vo.TerminalIdUpdateVo;
@ -20,7 +20,7 @@ public interface TerminalsDao {
List<ChannelAndTermDto> selectChannelAndTermList(@Param("status") Integer status);
List<TerminalsAndLineAndChannelDto> selectTermAndLineList(@Param("termidlist") List<Integer> termidlist, @Param("status") Integer status);
List<TerminalsAndStatusDto> selectTermAndStatusList( @Param("status") Integer status);
Terminals selectByCmdid(@Param("cmdid") String cmdid, @Param("status") Integer status);

@ -130,25 +130,25 @@
<select id="selectTreeList" resultMap="LineAndTerminalMap">
select
z.id as id,
z.name as name,
z.dy_value as dyvalue,
x.id as line_id,
x.name as line_name,
x.bs_manufacturer as bs_manufacturer,
x.dy_level_id as dy_level_id,
y.id as term_id,
y.tower_id as tower_id,
t.name as tower_name,
y.cmdid as cmdid,
y.equip_name as equip_name,
y.display_name as display_name,
y.model as model,
f.last_heartbeat as last_heartbeat
from ((((dy_level z left join `lines` x on z.id = x.dy_level_id and x.status = #{status} and z.status = #{status})
left join terminals y on x.id = y.line_id and y.status = #{status})
left join towers t on y.tower_id = t.id)
left join terminal_status f on f.term_id = y.id)
a.id as id,
a.name as name,
a.dy_value as dyvalue,
b.id as line_id,
b.name as line_name,
b.bs_manufacturer as bs_manufacturer,
b.dy_level_id as dy_level_id,
c.id as term_id,
c.tower_id as tower_id,
d.name as tower_name,
c.cmdid as cmdid,
c.equip_name as equip_name,
c.display_name as display_name,
c.model as model,
e.last_heartbeat as last_heartbeat
from ((((dy_level a left join `lines` b on a.id = b.dy_level_id and b.status = #{status} and a.status = #{status})
left join towers d on c.tower_id = d.id)
left join terminals c on b.id = c.line_id and c.status = #{status})
left join terminal_status e on e.term_id = c.id)
</select>
<select id="selectTreeListByChannelId" resultMap="LineAndTerminalNoHeartMap">

@ -22,6 +22,19 @@
<result column="status" jdbcType="INTEGER" property="status"/>
</resultMap>
<resultMap id="TermAndChannelMap" type="com.shxy.xymanager_common.dto.TermAndChannelDto">
<result column="termid" jdbcType="INTEGER" property="termid"/>
<collection property="list" javaType="list" ofType="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"/>
<result column="max_resolution_height" jdbcType="INTEGER" property="maxResolutionHeight"/>
<result column="status" jdbcType="INTEGER" property="status"/>
</collection>
</resultMap>
<resultMap id="LineAndTerminalMap" type="com.shxy.xymanager_common.dto.DyLineAndTerminalAndChannelDto">
<id column="id" jdbcType="INTEGER" property="id"/>
@ -62,6 +75,25 @@
where status = #{status}
</select>
<select id="selectTermChannelList" resultMap="TermAndChannelMap">
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,
y.max_resolution_height as max_resolution_height,
y.status as status
from terminal_channel_mapper x,
terminal_channels y
where x.channel_id = y.id
<if test="status != null">
and y.status = #{status}
</if>
order by y.id asc
</select>
<select id="selectChannelCount" parameterType="com.shxy.xymanager_common.vo.TerminalChannelVo"
resultType="java.lang.Integer">
select

@ -68,8 +68,8 @@
</foreach>
</if>
<if test="labellist != null and labellist.size > 0">
and
<foreach collection="labellist" item="item" index="index" separator="or">
and (
<foreach collection="labellist" item="item" index="index" separator="or">
(
<if test="item.label != null">
label = #{item.label}
@ -79,6 +79,7 @@
</if>
)
</foreach>
)
</if>
order by a.alarm_time desc
</select>

@ -22,12 +22,10 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<resultMap id="LineAndGtAndTermMap" type="com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto">
<resultMap id="TermAndStatusMap" type="com.shxy.xymanager_common.dto.TerminalsAndStatusDto">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="line_id" jdbcType="INTEGER" property="lineid"/>
<result column="line_name" jdbcType="VARCHAR" property="linename"/>
<result column="tower_id" jdbcType="INTEGER" property="towerid"/>
<result column="tower_name" jdbcType="VARCHAR" property="towername"/>
<result column="cmdid" jdbcType="VARCHAR" property="cmdid"/>
<result column="org_id" jdbcType="SMALLINT" property="orgId"/>
<result column="equip_name" jdbcType="VARCHAR" property="equipName"/>
@ -45,11 +43,6 @@
<result column="battery_capacity" jdbcType="FLOAT" property="batteryCapacity"/>
<result column="battery_voltage" jdbcType="FLOAT" property="batteryVoltage"/>
<result column="last_heartbeat" jdbcType="INTEGER" property="lastHeartbeat"/>
<collection property="list" javaType="list" ofType="com.shxy.xymanager_common.dto.TerminalChannelsDto">
<result column="channel_id" jdbcType="INTEGER" property="id"/>
<result column="channel_name" jdbcType="VARCHAR" property="name"/>
<result column="alias" jdbcType="VARCHAR" property="alias"/>
</collection>
</resultMap>
<resultMap id="ChannelAndTerm" type="com.shxy.xymanager_common.dto.ChannelAndTermDto">
@ -122,13 +115,11 @@
where a.status = #{status}
</select>
<select id="selectTermAndLineList" resultMap="LineAndGtAndTermMap">
<select id="selectTermAndStatusList" resultMap="TermAndStatusMap">
select
a.id as id,
a.line_id as line_id,
b.name as line_name,
a.tower_id as tower_id,
c.name as tower_name,
a.cmdid as cmdid,
a.org_id as org_id,
a.equip_name as equip_name,
@ -141,26 +132,15 @@
a.bs_identifier as bs_identifier,
a.latitude as latitude,
a.longitude as longitude,
d.alias as alias,
e.id as channel_id,
e.channel_name as channel_name,
ts.signal_strength_4g as signal_strength_4g,
ts.boot_time as boot_time,
ts.battery_capacity as battery_capacity,
ts.battery_voltage as battery_voltage,
ts.last_heartbeat as last_heartbeat
b.signal_strength_4g as signal_strength_4g,
b.boot_time as boot_time,
b.battery_capacity as battery_capacity,
b.battery_voltage as battery_voltage,
b.last_heartbeat as last_heartbeat
from
(((((terminals a left join `lines` b on a.line_id = b.id )
left join towers c on a.tower_id = c.id)
left join terminal_channel_mapper d on a.id = d.term_id)
left join terminal_channels e on d.channel_id = e.id)
left join terminal_status ts on ts.term_id = a.id)
WHERE a.status = #{status}
<if test="termidlist != null and termidlist.size >0">
and a.id in
<foreach collection="termidlist" item="id" index="index" separator="," open="(" close=")">
#{id}
</foreach>
(terminals a left join terminal_status b on a.id = b.term_id )
<if test="status != null">
a.status = #{status}
</if>
order by a.create_time desc
</select>

@ -25,7 +25,7 @@
t.status as status
from towers t,
`lines` l
where t.line_id = l.id and t.status = #{status,jdbcType=INTEGER} order by t.`order` asc
where t.line_id = l.id and t.status = #{status,jdbcType=INTEGER} order by t.`order` asc,l.id desc
</select>
<select id="selectAllByLineid" resultType="com.shxy.xymanager_common.entity.Towers">

@ -31,7 +31,6 @@ public class XyCache {
cacheService.updateGolobalMap();
}

@ -1,6 +1,7 @@
package com.shxy.xymanager_service.impl;
import com.shxy.xymanager_common.dto.LineAndDyNameDto;
import com.shxy.xymanager_common.dto.TermAndChannelDto;
import com.shxy.xymanager_common.dto.TowerDto;
import com.shxy.xymanager_common.entity.*;
import com.shxy.xymanager_common.enums.CommonStatus;
@ -199,9 +200,6 @@ public class CacheServiceImpl implements CacheService {
// }
@Override
@Cacheable(value = "globalMap")
public Map<String, String> getGolobalMap() {
@ -247,6 +245,18 @@ public class CacheServiceImpl implements CacheService {
return termchannelMap;
}
@Override
@Cacheable(value = "termAndchannelMap")
public Map<Integer, TermAndChannelDto> getTermAndChannelMap() {
Map<Integer, TermAndChannelDto> termchannelMap = new HashMap<Integer, TermAndChannelDto>();
List<TermAndChannelDto> list = terminalChannelsDao.selectTermChannelList(CommonStatus.EFFECTIVE.value());
for (TermAndChannelDto item : list) {
termchannelMap.put(item.getTermid(), item);
}
return termchannelMap;
}
@Override
@Cacheable(value = "towerMap")
public Map<Integer, TowerDto> getTowerMap() {
@ -326,6 +336,17 @@ public class CacheServiceImpl implements CacheService {
return termchannelMap;
}
@Override
@CachePut(value = "termAndchannelMap")
public Map<Integer, TermAndChannelDto> updateTermAndChannelMap() {
Map<Integer, TermAndChannelDto> termchannelMap = new HashMap<Integer, TermAndChannelDto>();
List<TermAndChannelDto> list = terminalChannelsDao.selectTermChannelList(CommonStatus.EFFECTIVE.value());
for (TermAndChannelDto item : list) {
termchannelMap.put(item.getTermid(), item);
}
return termchannelMap;
}
@Override
@CachePut(value = "towerMap")
public Map<Integer, TowerDto> updateTowerMap() {

@ -140,6 +140,7 @@ public class TerminalAlarmServiceImpl implements TerminalAlarmService {
// List<TerminalAlarmListModel.AlarmBean> alarmBeans = BeanUtil.copyToList(list, TerminalAlarmListModel.AlarmBean.class, CopyOptions.create().ignoreCase());
List<TerminalAlarmListModel.AlarmBean> alarmBeans = new ArrayList<>();
log.info("查询出来的告警图片数据列表:" + list.toArray());
for (TerminalImgAlarmsDto item : list) {
TerminalAlarmListModel.AlarmBean alarmBean = new TerminalAlarmListModel.AlarmBean();
Integer termId = item.getTermId();

@ -9,10 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.constant.Constants;
import com.shxy.xymanager_common.dto.DyLineAndTerminalNoHeartDto;
import com.shxy.xymanager_common.dto.PhotoMarkDto;
import com.shxy.xymanager_common.dto.TerminalInfoDto;
import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto;
import com.shxy.xymanager_common.dto.*;
import com.shxy.xymanager_common.entity.TerminalChannelMapper;
import com.shxy.xymanager_common.entity.TerminalStatus;
import com.shxy.xymanager_common.entity.Terminals;
@ -27,7 +24,6 @@ import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_common.util.TerminalUtils;
import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.*;
import com.shxy.xymanager_service.cache.XyCache;
import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.TerminalService;
import lombok.extern.slf4j.Slf4j;
@ -90,28 +86,66 @@ public class TerminalServiceImpl implements TerminalService {
int pageindex = vo.getPageindex();
int pagesize = vo.getPagesize();
PageUtils.SetPage(pageindex, pagesize);
List<Integer> termidlist = new ArrayList<>();
List<Terminals> list = terminalsDao.selectAll(CommonStatus.EFFECTIVE.value());
if (CollectionUtil.isNotEmpty(list)) {
for (Terminals item : list) {
termidlist.add(item.getId());
}
List<TerminalsAndLineAndChannelDto> list2 = terminalsDao.selectTermAndLineList(termidlist, CommonStatus.EFFECTIVE.value());
boolean empty = CollectionUtil.isEmpty(list2);
if (empty) {
model.setList(new ArrayList<>());
} else {
List<TerminalListModel.TerminalsBean> beans = BeanUtil.copyToList(list2, TerminalListModel.TerminalsBean.class, CopyOptions.create().ignoreCase());
for (TerminalListModel.TerminalsBean item : beans) {
boolean b = TerminalUtils.judgeTerminalStatus(item.getLastHeartbeat());
item.setIsonline(b);
List<TerminalsAndStatusDto> list2 = terminalsDao.selectTermAndStatusList(CommonStatus.EFFECTIVE.value());
boolean empty = CollectionUtil.isEmpty(list2);
if (empty) {
model.setList(new ArrayList<>());
} else {
Map<Integer, TowerDto> towerMap = cacheService.getTowerMap();
Map<Integer, TermAndChannelDto> termAndChannelMap = cacheService.getTermAndChannelMap();
ArrayList<TerminalListModel.TerminalsBean> beanlist = new ArrayList<>();
for (TerminalsAndStatusDto item : list2) {
TerminalListModel.TerminalsBean terminalsBean = new TerminalListModel.TerminalsBean();
terminalsBean.setCmdId(item.getCmdid());
Integer towerid = item.getTowerid();
terminalsBean.setId(item.getId());
terminalsBean.setTowerId(towerid);
terminalsBean.setTowerName(towerMap.get(towerid).getName());
terminalsBean.setLineId(towerMap.get(towerid).getLineId());
terminalsBean.setLineName(towerMap.get(towerid).getLineName());
terminalsBean.setCmdId(item.getCmdid());
terminalsBean.setOrgId(item.getOrgId());
terminalsBean.setEquipName(item.getEquipName());
terminalsBean.setDisplayName(item.getDisplayName());
terminalsBean.setModel(item.getModel());
terminalsBean.setEssentialInfoVersion(item.getEssentialInfoVersion());
terminalsBean.setHasPan(item.getHasPan());
terminalsBean.setBsManufacturer(item.getBsManufacturer());
terminalsBean.setBsProductionDate(item.getBsProductionDate());
terminalsBean.setBsIdentifier(item.getBsIdentifier());
terminalsBean.setLatitude(item.getLatitude());
terminalsBean.setLongitude(item.getLongitude());
terminalsBean.setSignalStrength4g(item.getSignalStrength4g());
terminalsBean.setBootTime(item.getBootTime());
terminalsBean.setBatteryCapacity(item.getBatteryCapacity());
terminalsBean.setBatteryVoltage(item.getBatteryVoltage());
terminalsBean.setLastHeartbeat(item.getLastHeartbeat());
boolean b = TerminalUtils.judgeTerminalStatus(item.getLastHeartbeat());
terminalsBean.setIsonline(b);
TermAndChannelDto termAndChannelDto = termAndChannelMap.get(item.getId());
ArrayList<TerminalListModel.ChannelBeans> list = new ArrayList<>();
if (BeanUtil.isEmpty(termAndChannelDto)) {
terminalsBean.setList(list);
} else {
List<TermChannelAndMapperDto> channellist = termAndChannelDto.getChannellist();
if (CollectionUtil.isEmpty(channellist)) {
terminalsBean.setList(list);
} else {
for (TermChannelAndMapperDto dto : channellist) {
TerminalListModel.ChannelBeans e = new TerminalListModel.ChannelBeans();
e.setAlias(dto.getAlias());
e.setId(dto.getId());
e.setName(dto.getChannelname());
list.add(e);
}
terminalsBean.setList(list);
}
}
model.setList(beans);
beanlist.add(terminalsBean);
}
} else {
model.setList(new ArrayList<>());
model.setList(beanlist);
}
PageInfo pageData = PageUtils.getPageData(list);
PageInfo pageData = PageUtils.getPageData(list2);
int currentpage = pageData.getPageNum();
model.setCurrentpage(currentpage);
long total = pageData.getTotal();

@ -1,6 +1,7 @@
package com.shxy.xymanager_service.service;
import com.shxy.xymanager_common.dto.LineAndDyNameDto;
import com.shxy.xymanager_common.dto.TermAndChannelDto;
import com.shxy.xymanager_common.dto.TowerDto;
import com.shxy.xymanager_common.entity.*;
import org.springframework.cache.annotation.CacheEvict;
@ -94,6 +95,8 @@ public interface CacheService {
Map<Integer, TerminalChannels> getTermChannelMap();
Map<Integer, TermAndChannelDto> getTermAndChannelMap();
Map<Integer, TowerDto> getTowerMap();
Map<Integer, Terminals> getTerminalMap();
@ -102,6 +105,8 @@ public interface CacheService {
Map<Integer, TerminalChannels> updateTermChannelMap();
Map<Integer, TermAndChannelDto> updateTermAndChannelMap();
Map<Integer, TowerDto> updateTowerMap();
Map<Integer, Terminals> updateTerminalMap();

Loading…
Cancel
Save