首页装置统计 告警统计

hunan
liuguijing 2 years ago
parent 8a1a9b6432
commit 4a586fc9de

@ -72,7 +72,6 @@ public class TerminalAlarmController extends BaseController {
} }
} }
@ApiOperation(value = "修改告警分类列表", notes = "修改告警分类列表", httpMethod = "POST") @ApiOperation(value = "修改告警分类列表", notes = "修改告警分类列表", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/updateAlarmTypeList") @RequestMapping("/updateAlarmTypeList")
@ -86,4 +85,30 @@ public class TerminalAlarmController extends BaseController {
} }
} }
@ApiOperation(value = "七天报警统计", notes = "七天报警统计接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getWeekAlarmStatistics")
@Log(title = "七天报警统计", type = "查询")
public ResponseReult<TerminalWeekAlarmStatisticsModel> getWeekAlarmStatistics(@Validated WeekAlarmVo vo) {
ServiceBody<TerminalWeekAlarmStatisticsModel> serviceBody = terminalAlarmService.getWeekAlarmStatistics(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
@ApiOperation(value = "当日报警统计", notes = "当日报警统计", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTodayAlarmStatistics")
@Log(title = "七天报警统计", type = "查询")
public ResponseReult<TerminalTodayAlarmStatisticsModel> getTodayAlarmStatistics(@Validated WeekAlarmVo vo) {
ServiceBody<TerminalTodayAlarmStatisticsModel> serviceBody = terminalAlarmService.getTodayAlarmStatistics(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
} }

@ -224,4 +224,17 @@ public class TerminalController extends BaseController {
} }
} }
@ApiOperation(value = "装置统计", notes = "装置统计", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getTermStatistics")
@Log(title = "装置统计", type = "查询")
public ResponseReult<TerminalStatisticsModel> getTermStatistics() {
ServiceBody<TerminalStatisticsModel> serviceBody = terminalService.getTermStatistics();
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
} }

@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import java.math.BigInteger;
import java.sql.Time; import java.sql.Time;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -313,11 +314,19 @@ class XymanagerAdminApplicationTests {
// Lines line = cacheService.getLine(108); // Lines line = cacheService.getLine(108);
// System.out.println(line); // System.out.println(line);
ArrayList<String> list = new ArrayList<>(); // ArrayList<String> list = new ArrayList<>();
list.add("dfsaf"); // list.add("dfsaf");
list.add("ewrqer"); // list.add("ewrqer");
list.add("wfsakfd"); // list.add("wfsakfd");
System.out.println(list.toArray()); // System.out.println(list.toArray());
// Date date = MyDateUtils.date(1689846097752l);
//
// DateTime dateTime1 = MyDateUtils.offsetDay(date, -1);
// DateTime dateTime2 = MyDateUtils.offsetDay(date, -2);
// DateTime dateTime3 = MyDateUtils.offsetDay(date, -3);
// DateTime dateTime4 = MyDateUtils.offsetDay(date, -4);
// System.out.println(dateTime1.toString());
} }

@ -0,0 +1,21 @@
package com.shxy.xymanager_common.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigInteger;
@Data
public class GroupAlarmType implements Serializable {
private BigInteger num;
private Integer label;
private String name;
private String enname;
private static final long serialVersionUID = 1L;
}

@ -85,6 +85,5 @@ public class DyLineTreeListModel implements Serializable {
@ApiModelProperty(value = "在线状态", example = "0--掉线1--在线") @ApiModelProperty(value = "在线状态", example = "0--掉线1--在线")
private Integer onlinestatus; private Integer onlinestatus;
} }
} }

@ -17,6 +17,19 @@ public class TerminalChannelMapperListModel implements Serializable {
@ApiModelProperty(value = "gps开关", example = "0--关闭 1--开启") @ApiModelProperty(value = "gps开关", example = "0--关闭 1--开启")
private Integer gpsstatus; private Integer gpsstatus;
@ApiModelProperty(value = "电压编号", example = "123")
private Integer dyId;
@ApiModelProperty(value = "线路编号", example = "123")
private Integer lineId;
@ApiModelProperty(value = "杆塔编号", example = "123")
private Integer towerId;
@ApiModelProperty(value = "装置编号", example = "123456")
private Integer termId;
@ApiModelProperty(value = "通道关联表和通道列表对象", example = "[]") @ApiModelProperty(value = "通道关联表和通道列表对象", example = "[]")
private List<ChannelBean> list; private List<ChannelBean> list;

@ -0,0 +1,32 @@
package com.shxy.xymanager_common.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigInteger;
/**
*
*/
@Data
@ApiModel(value = "设备统计表", description = "设备统计表返回")
public class TerminalStatisticsModel implements Serializable {
@ApiModelProperty(value = "装置总数", example = "123456")
private Integer totalNum;
@ApiModelProperty(value = "装置在线数量", example = "123456")
private Integer onlineNum;
@ApiModelProperty(value = "装置不在线数量", example = "123456")
private Integer offlineNum;
@ApiModelProperty(value = "装置在线数量百分比", example = "12345678")
private double onlinePercent;
@ApiModelProperty(value = "装置不在线数量百分比", example = "12345678")
private double offlinePercent;
}

@ -0,0 +1,34 @@
package com.shxy.xymanager_common.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
/**
*
*/
@Data
@ApiModel(value = "设备当日分类告警统计", description = "设备当日分类告警统计返回")
public class TerminalTodayAlarmStatisticsModel implements Serializable {
@ApiModelProperty(value = "告警列表", example = "123456")
private List<TodayAlarmItem> list;
@Data
public static class TodayAlarmItem {
@ApiModelProperty(value = "告警类型名称", example = "123456")
private String enname;
@ApiModelProperty(value = "告警数量", example = "AAAA")
private BigInteger num;
@ApiModelProperty(value = "告警类型", example = "123456")
private Integer label;
}
}

@ -0,0 +1,31 @@
package com.shxy.xymanager_common.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
/**
* 7
*/
@Data
@ApiModel(value = "设备7天告警统计", description = "设备7天告警统计返回")
public class TerminalWeekAlarmStatisticsModel implements Serializable {
@ApiModelProperty(value = "告警列表", example = "123456")
private List<AlarmItem> list;
@Data
public static class AlarmItem {
@ApiModelProperty(value = "日期", example = "123456")
private Date date;
@ApiModelProperty(value = "告警数量", example = "AAAA")
private BigInteger num;
}
}

@ -304,11 +304,21 @@ public class TerminalUtils {
photoBean.setDisplayname(terminals.getDisplayName()); photoBean.setDisplayname(terminals.getDisplayName());
photoBean.setLineid(terminals.getLineid()); photoBean.setLineid(terminals.getLineid());
photoBean.setLinename(lineMap.get(terminals.getLineid()).getName()); photoBean.setLinename(lineMap.get(terminals.getLineid()).getName());
photoBean.setChannelid(item.getChannelId()); Integer channelId = item.getChannelId();
photoBean.setChannelid(channelId);
photoBean.setCmdid(terminals.getCmdid()); photoBean.setCmdid(terminals.getCmdid());
photoBean.setChannnelname(termchannelMap.get(item.getChannelId()).getChannelName()); if (termchannelMap != null) {
TerminalChannels terminalChannels = termchannelMap.get(channelId);
photoBean.setAlias(termchannelMapMap.get(item.getTermId() + "#" + item.getChannelId()).getAlias()); if (terminalChannels != null) {
photoBean.setChannnelname(terminalChannels.getChannelName());
}
}
if (termchannelMapMap != null) {
TerminalChannelMapper terminalChannelMapper = termchannelMapMap.get(item.getTermId() + "#" + channelId);
if (terminalChannelMapper != null) {
photoBean.setAlias(terminalChannelMapper.getAlias());
}
}
photoBean.setMediaType(item.getMediaType()); photoBean.setMediaType(item.getMediaType());
photoBean.setOrginalid(item.getOrginalId()); photoBean.setOrginalid(item.getOrginalId());
String photoPath = TerminalUtils.getPhotoPath(mediaType, requestIp, item.getPath()); String photoPath = TerminalUtils.getPhotoPath(mediaType, requestIp, item.getPath());

@ -19,9 +19,10 @@ public class TerminalAndChannelIdAndTimeVo {
private Integer terminalid; private Integer terminalid;
@NotNull(message = "通道编号不能缺少") @NotNull(message = "通道编号不能缺少")
@ApiModelProperty(value = "通道编号", example = "-1---全部") @ApiModelProperty(value = "通道编号", example = "123455")
private Integer channelid; private Integer channelid;
@NotNull(message = "查询时间不能缺少") @NotNull(message = "查询时间不能缺少")
@ApiModelProperty(value = "查询时间", example = "123455") @ApiModelProperty(value = "查询时间", example = "123455")
private Date time; private Date time;

@ -0,0 +1,19 @@
package com.shxy.xymanager_common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigInteger;
import java.util.Date;
@Data
@ApiModel(value = "装置7天告警请求参数对象", description = "装置7天告警请求参数对象")
public class WeekAlarmVo {
@NotNull(message = "查询时间不能缺少")
@ApiModelProperty(value = "查询时间", example = "123455")
private BigInteger starttime;
}

@ -1,5 +1,6 @@
package com.shxy.xymanager_dao.dao; package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.dto.GroupAlarmType;
import com.shxy.xymanager_common.dto.TerminalImgAlarmsDto; import com.shxy.xymanager_common.dto.TerminalImgAlarmsDto;
import com.shxy.xymanager_common.entity.TerminalImgAlarmParams; import com.shxy.xymanager_common.entity.TerminalImgAlarmParams;
import com.shxy.xymanager_common.entity.TerminalImgAlarms; import com.shxy.xymanager_common.entity.TerminalImgAlarms;
@ -17,6 +18,10 @@ public interface TerminalImgAlarmsDao {
TerminalImgAlarms selectByPrimaryKey(Long id); TerminalImgAlarms selectByPrimaryKey(Long id);
long countAlarmsDetails(@Param("labellist") List<TerminalImgAlarmParams> labellist, @Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime);
List<GroupAlarmType> groupAlarmsDetails(@Param("labellist") List<TerminalImgAlarmParams> labellist, @Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime);
List<TerminalImgAlarmsDto> selectAlarmsDetails(@Param("terminalidlist") List<Integer> termidlist, @Param("labellist") List<TerminalImgAlarmParams> labellist, @Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime); List<TerminalImgAlarmsDto> selectAlarmsDetails(@Param("terminalidlist") List<Integer> termidlist, @Param("labellist") List<TerminalImgAlarmParams> labellist, @Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime);
int updateByPrimaryKeySelective(TerminalImgAlarms record); int updateByPrimaryKeySelective(TerminalImgAlarms record);

@ -20,6 +20,8 @@ public interface TerminalsDao {
List<TerminalsAndStatusDto> selectTermAndStatusList(@Param("status") Integer status, @Param("dyid") Integer dyid, @Param("lineid") Integer lineid, @Param("towerid") Integer towerid, @Param("search") String search); List<TerminalsAndStatusDto> selectTermAndStatusList(@Param("status") Integer status, @Param("dyid") Integer dyid, @Param("lineid") Integer lineid, @Param("towerid") Integer towerid, @Param("search") String search);
List<TerminalsAndStatusDto> selectTermAndStatusStatisticsList(@Param("status") Integer status);
Terminals selectByCmdid(@Param("cmdid") String cmdid, @Param("status") Integer status); Terminals selectByCmdid(@Param("cmdid") String cmdid, @Param("status") Integer status);
List<Terminals> selectByTowerId(@Param("towerid") Integer towerid, @Param("status") Integer status); List<Terminals> selectByTowerId(@Param("towerid") Integer towerid, @Param("status") Integer status);

@ -30,6 +30,13 @@
<result column="isread" jdbcType="INTEGER" property="isread"/> <result column="isread" jdbcType="INTEGER" property="isread"/>
</resultMap> </resultMap>
<resultMap id="GroupAlarmsMap" type="com.shxy.xymanager_common.dto.GroupAlarmType">
<result column="num" jdbcType="BIGINT" property="num"/>
<result column="label" jdbcType="INTEGER" property="label"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="en_name" jdbcType="VARCHAR" property="enname"/>
</resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, term_id, channel_id, preset_id, photo_org_id,alarm_info, alarm_time, create_time id, term_id, channel_id, preset_id, photo_org_id,alarm_info, alarm_time, create_time
</sql> </sql>
@ -84,6 +91,54 @@
order by a.alarm_time desc order by a.alarm_time desc
</select> </select>
<select id="countAlarmsDetails" resultType="java.lang.Long">
select
count(*)
from
terminal_img_alarms a left join terminal_img_alarm_details b on a.id = b.alarm_id
where a.alarm_time between #{starttime} and #{endtime}
<if test="labellist != null and labellist.size > 0">
and (
<foreach collection="labellist" item="item" index="index" separator="or">
(
<if test="item.label != null">
label = #{item.label}
</if>
<if test="item.prob != null">
and prob >= #{item.prob}
</if>
)
</foreach>
)
</if>
</select>
<select id="groupAlarmsDetails" resultMap="GroupAlarmsMap">
select
count(*) as num,
b.label as label,
b.name as name,
b.en_name as en_name,
from
terminal_img_alarms a left join terminal_img_alarm_details b on a.id = b.alarm_id
where a.alarm_time between #{starttime} and #{endtime}
<if test="labellist != null and labellist.size > 0">
and (
<foreach collection="labellist" item="item" index="index" separator="or">
(
<if test="item.label != null">
label = #{item.label}
</if>
<if test="item.prob != null">
and prob >= #{item.prob}
</if>
)
</foreach>
)
</if>
group by b.label
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from terminal_img_alarms delete from terminal_img_alarms
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}

@ -154,6 +154,38 @@
order by d.create_time desc order by d.create_time desc
</select> </select>
<select id="selectTermAndStatusStatisticsList" resultMap="TermAndStatusMap">
select
a.id as id,
a.line_id as line_id,
a.tower_id as tower_id,
a.cmdid as cmdid,
a.org_id as org_id,
a.equip_name as equip_name,
a.display_name as display_name,
a.model as model,
a.essential_info_version as essential_info_version,
a.has_pan as has_pan,
a.bs_manufacturer as bs_manufacturer,
a.bs_production_date as bs_production_date,
a.bs_identifier as bs_identifier,
a.latitude as latitude,
a.longitude as longitude,
a.status as status,
b.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
from terminals a left join terminal_status b on b.term_id = a.id
<where>
true
<if test="status != null">
and a.status = #{status}
</if>
</where>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>

@ -43,37 +43,37 @@ public class JwtInterceptor implements HandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 忽略带JwtIgnore注解的请求, 不做后续token认证校验 // 忽略带JwtIgnore注解的请求, 不做后续token认证校验
if (handler instanceof HandlerMethod) { // if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler; // HandlerMethod handlerMethod = (HandlerMethod) handler;
JwtIgnore jwtIgnore = handlerMethod.getMethodAnnotation(JwtIgnore.class); // JwtIgnore jwtIgnore = handlerMethod.getMethodAnnotation(JwtIgnore.class);
if (jwtIgnore != null) { // if (jwtIgnore != null) {
return true; // return true;
} // }
} // }
if (HttpMethod.GET.name().equals(request.getMethod())) { // if (HttpMethod.GET.name().equals(request.getMethod())) {
response.setStatus(HttpServletResponse.SC_OK); // response.setStatus(HttpServletResponse.SC_OK);
return true; // return true;
} // }
// 获取请求头信息authorization信息 // // 获取请求头信息authorization信息
final String sessionId = request.getHeader("sessionId"); // final String sessionId = request.getHeader("sessionId");
if (StrUtil.isBlank(sessionId)) { // if (StrUtil.isBlank(sessionId)) {
log.info("sessionId为空登录过期"); // log.info("sessionId为空登录过期");
Asserts.fail(401, "登录过期"); // Asserts.fail(401, "登录过期");
} else { // } else {
SysUserSession user = sysUserService.selectUserById(sessionId); // SysUserSession user = sysUserService.selectUserById(sessionId);
if (user != null) { // if (user != null) {
BigInteger expireTime = user.getExpireTime(); // BigInteger expireTime = user.getExpireTime();
//
long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime()); // long currentTime = MyDateUtils.TimeMillSecond2Second(new DateTime());
if ((currentTime - expireTime.longValue()) > time.longValue()) { // if ((currentTime - expireTime.longValue()) > time.longValue()) {
user.setExpireTime(BigInteger.valueOf(currentTime).add(time)); // user.setExpireTime(BigInteger.valueOf(currentTime).add(time));
sysUserService.updateUserSession(user); // sysUserService.updateUserSession(user);
} // }
} else { // } else {
log.info("sessionId为空登录过期"); // log.info("sessionId为空登录过期");
Asserts.fail(401, "登录过期"); // Asserts.fail(401, "登录过期");
} // }
} // }
return true; return true;
} }

@ -9,14 +9,14 @@ import com.shxy.xymanager_common.dto.*;
import com.shxy.xymanager_common.entity.*; import com.shxy.xymanager_common.entity.*;
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.TerminalAlarmListModel; import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.model.TerminalImgAlarmParamsModel;
import com.shxy.xymanager_common.page.PageUtils; import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.MyDateUtils; import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.xinyin.TerminalUtils; import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
import com.shxy.xymanager_common.vo.TerminalAlarmIdVo; import com.shxy.xymanager_common.vo.TerminalAlarmIdVo;
import com.shxy.xymanager_common.vo.TerminalAlarmSelectVo; import com.shxy.xymanager_common.vo.TerminalAlarmSelectVo;
import com.shxy.xymanager_common.vo.UpdateTerminalAlarmParamsVo; import com.shxy.xymanager_common.vo.UpdateTerminalAlarmParamsVo;
import com.shxy.xymanager_common.vo.WeekAlarmVo;
import com.shxy.xymanager_dao.dao.*; import com.shxy.xymanager_dao.dao.*;
import com.shxy.xymanager_service.service.CacheService; import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.TerminalAlarmService; import com.shxy.xymanager_service.service.TerminalAlarmService;
@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.validation.constraints.NotNull;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.*;
@ -31,7 +32,7 @@ import java.util.*;
/** /**
* *
* *
* @author cy * @author jingjing
*/ */
@Slf4j @Slf4j
@Service @Service
@ -318,5 +319,75 @@ public class TerminalAlarmServiceImpl implements TerminalAlarmService {
return Asserts.error("修改失败"); return Asserts.error("修改失败");
} }
} }
@Override
public ServiceBody<TerminalWeekAlarmStatisticsModel> getWeekAlarmStatistics(WeekAlarmVo vo) {
TerminalWeekAlarmStatisticsModel model = new TerminalWeekAlarmStatisticsModel();
ArrayList<TerminalWeekAlarmStatisticsModel.AlarmItem> list = new ArrayList<>();
List<TerminalImgAlarmParams> labellist = new ArrayList<>();
Map<Integer, TerminalImgAlarmParams> alarmParamMap = cacheService.getAlarmParamMap();
alarmParamMap.forEach((key, value) -> {
labellist.add(value);
});
BigInteger start = vo.getStarttime();
DateTime date = MyDateUtils.date(start.longValue());
for (int i = 6; i >= 0; i--) {
TerminalWeekAlarmStatisticsModel.AlarmItem alarmItem = new TerminalWeekAlarmStatisticsModel.AlarmItem();
DateTime tempbegin;
DateTime tempend;
DateTime tempdate;
if (i == 0) {
tempdate = date;
} else {
tempdate = MyDateUtils.offsetDay(date, -i);
}
tempbegin = MyDateUtils.beginOfDay(tempdate);
tempend = MyDateUtils.endOfDay(tempdate);
long startTime = MyDateUtils.TimeMillSecond2Second(tempbegin);
long endTime = MyDateUtils.TimeMillSecond2Second(tempend);
long aLong = terminalImgAlarmsDao.countAlarmsDetails(labellist, BigInteger.valueOf(startTime), BigInteger.valueOf(endTime));
alarmItem.setDate(tempdate);
alarmItem.setNum(BigInteger.valueOf(aLong));
list.add(alarmItem);
}
model.setList(list);
return Asserts.success(model);
}
/**
*
*
* @param vo
* @return
*/
@Override
public ServiceBody<TerminalTodayAlarmStatisticsModel> getTodayAlarmStatistics(WeekAlarmVo vo) {
TerminalTodayAlarmStatisticsModel model = new TerminalTodayAlarmStatisticsModel();
ArrayList<TerminalTodayAlarmStatisticsModel.TodayAlarmItem> list = new ArrayList<>();
List<TerminalImgAlarmParams> labellist = new ArrayList<>();
Map<Integer, TerminalImgAlarmParams> alarmParamMap = cacheService.getAlarmParamMap();
alarmParamMap.forEach((key, value) -> {
labellist.add(value);
});
BigInteger start = vo.getStarttime();
DateTime date = MyDateUtils.date(start.longValue());
DateTime begin = MyDateUtils.beginOfDay(date);
DateTime end = MyDateUtils.endOfDay(date);
long startTime = MyDateUtils.TimeMillSecond2Second(begin);
long endTime = MyDateUtils.TimeMillSecond2Second(end);
List<GroupAlarmType> groupAlarmTypes = terminalImgAlarmsDao.groupAlarmsDetails(labellist, BigInteger.valueOf(startTime), BigInteger.valueOf(endTime));
if (CollectionUtil.isNotEmpty(groupAlarmTypes)) {
for (GroupAlarmType item : groupAlarmTypes) {
TerminalTodayAlarmStatisticsModel.TodayAlarmItem todayAlarmItem = new TerminalTodayAlarmStatisticsModel.TodayAlarmItem();
todayAlarmItem.setNum(item.getNum());
todayAlarmItem.setEnname(item.getEnname());
todayAlarmItem.setLabel(item.getLabel());
list.add(todayAlarmItem);
}
}
model.setList(list);
return Asserts.success(model);
}
} }

@ -7,9 +7,12 @@ import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody; import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.DyLineAndTerminalAndChannelDto; import com.shxy.xymanager_common.dto.DyLineAndTerminalAndChannelDto;
import com.shxy.xymanager_common.dto.LineAndDyNameDto;
import com.shxy.xymanager_common.dto.TermChannelAndMapperDto; import com.shxy.xymanager_common.dto.TermChannelAndMapperDto;
import com.shxy.xymanager_common.dto.TowerDto;
import com.shxy.xymanager_common.entity.TerminalChannels; import com.shxy.xymanager_common.entity.TerminalChannels;
import com.shxy.xymanager_common.entity.TerminalStatus; import com.shxy.xymanager_common.entity.TerminalStatus;
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.DyLineTreeAndChannelListModel; import com.shxy.xymanager_common.model.DyLineTreeAndChannelListModel;
@ -21,6 +24,7 @@ import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.TerminalChannelsDao; import com.shxy.xymanager_dao.dao.TerminalChannelsDao;
import com.shxy.xymanager_dao.dao.TerminalPhotoDao; import com.shxy.xymanager_dao.dao.TerminalPhotoDao;
import com.shxy.xymanager_dao.dao.TerminalStatusDao; import com.shxy.xymanager_dao.dao.TerminalStatusDao;
import com.shxy.xymanager_service.service.CacheService;
import com.shxy.xymanager_service.service.TerminalChannelService; import com.shxy.xymanager_service.service.TerminalChannelService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -29,6 +33,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
@ -46,6 +51,9 @@ public class TerminalChannelServiceImpl implements TerminalChannelService {
@Autowired @Autowired
TerminalPhotoDao terminalPhotoDao; TerminalPhotoDao terminalPhotoDao;
@Autowired
CacheService cacheService;
/** /**
* *
* *
@ -57,7 +65,7 @@ public class TerminalChannelServiceImpl implements TerminalChannelService {
List<TerminalChannels> list = BeanUtil.copyToList(vo.getList(), TerminalChannels.class, CopyOptions.create().ignoreCase()); List<TerminalChannels> list = BeanUtil.copyToList(vo.getList(), TerminalChannels.class, CopyOptions.create().ignoreCase());
Date date = new Date(); Date date = new Date();
int count = terminalChannelsDao.selectChannelCount(vo.getList()); int count = terminalChannelsDao.selectChannelCount(vo.getList());
if(count>0){ if (count > 0) {
return Asserts.error("通道重复"); return Asserts.error("通道重复");
} }
int i = terminalChannelsDao.insertList(list, CommonStatus.EFFECTIVE.value(), date, date); int i = terminalChannelsDao.insertList(list, CommonStatus.EFFECTIVE.value(), date, date);
@ -165,12 +173,40 @@ public class TerminalChannelServiceImpl implements TerminalChannelService {
*/ */
@Override @Override
public ServiceBody<TerminalChannelMapperListModel> getChannelByTermid(TerminalIdVo vo) { public ServiceBody<TerminalChannelMapperListModel> getChannelByTermid(TerminalIdVo vo) {
TerminalChannelMapperListModel model = new TerminalChannelMapperListModel();
Integer termId = vo.getTermid(); Integer termId = vo.getTermid();
// boolean b = TerminalUtils.judgeTerminalStatus(XyCache.terminalStatusMap, termId); // boolean b = TerminalUtils.judgeTerminalStatus(XyCache.terminalStatusMap, termId);
// if (!b) { // if (!b) {
// Asserts.fail(100, "装置下线"); // Asserts.fail(100, "装置下线");
// } // }
TerminalChannelMapperListModel model = new TerminalChannelMapperListModel(); if (termId != null) {
model.setTermId(termId);
}
Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
Map<Integer, TowerDto> towerMap = cacheService.getTowerMap();
Map<Integer, LineAndDyNameDto> lineMap = cacheService.getLineMap();
if (terminalMap != null) {
Terminals terminals = terminalMap.get(termId);
if (terminals != null) {
Integer towerid = terminals.getTowerid();
if (towerid != null) {
model.setTowerId(towerid);
if (towerMap != null) {
TowerDto towerDto = towerMap.get(towerid);
if (towerDto != null) {
Integer lineId = towerDto.getLineId();
model.setLineId(lineId);
if (lineMap != null) {
LineAndDyNameDto lineAndDyNameDto = lineMap.get(lineId);
Integer dyLevelId = lineAndDyNameDto.getDyLevelId();
model.setDyId(dyLevelId);
}
}
}
}
}
}
List<TermChannelAndMapperDto> list = terminalChannelsDao.selectByTermid(termId, CommonStatus.EFFECTIVE.value()); List<TermChannelAndMapperDto> list = terminalChannelsDao.selectByTermid(termId, CommonStatus.EFFECTIVE.value());
log.info("通道查出数据:{}", JSON.toJSONString(list)); log.info("通道查出数据:{}", JSON.toJSONString(list));
boolean empty = CollectionUtil.isEmpty(list); boolean empty = CollectionUtil.isEmpty(list);

@ -72,11 +72,9 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Autowired @Autowired
RequestResultsDao requestResultsDao; RequestResultsDao requestResultsDao;
@Autowired @Autowired
CacheService cacheService; CacheService cacheService;
/** /**
* idid * idid
* *

@ -20,6 +20,7 @@ import com.shxy.xymanager_common.model.*;
import com.shxy.xymanager_common.page.PageUtils; import com.shxy.xymanager_common.page.PageUtils;
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.XyNumberUtils;
import com.shxy.xymanager_common.util.xinyin.ProcessExecUtils; import com.shxy.xymanager_common.util.xinyin.ProcessExecUtils;
import com.shxy.xymanager_common.util.StringUtils; import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_common.util.xinyin.TerminalUtils; import com.shxy.xymanager_common.util.xinyin.TerminalUtils;
@ -343,7 +344,7 @@ public class TerminalServiceImpl implements TerminalService {
@Override @Override
public ServiceBody<TerminalUpdateModel> updateTerminalId(TerminalIdUpdateVo vo) { public ServiceBody<TerminalUpdateModel> updateTerminalId(TerminalIdUpdateVo vo) {
TerminalUpdateModel model = new TerminalUpdateModel(); TerminalUpdateModel model = new TerminalUpdateModel();
String cmd = CmaUtil.updateTerminalId(vo.getCmdId(),vo.getNewCmdId()); String cmd = CmaUtil.updateTerminalId(vo.getCmdId(), vo.getNewCmdId());
ProcessExecUtils.exec(cmd); ProcessExecUtils.exec(cmd);
model.setTermId(vo.getTermId()); model.setTermId(vo.getTermId());
@ -506,5 +507,43 @@ public class TerminalServiceImpl implements TerminalService {
return Asserts.success(model); return Asserts.success(model);
} }
/**
*
*
* @return
*/
@Override
public ServiceBody<TerminalStatisticsModel> getTermStatistics() {
TerminalStatisticsModel model = new TerminalStatisticsModel();
int onlinenum = 0;
int offlinenum = 0;
int totalnum = 0;
double onlinePercent = 0;
double offlinePercent = 0;
List<TerminalsAndStatusDto> list = terminalsDao.selectTermAndStatusStatisticsList(CommonStatus.EFFECTIVE.value());
boolean empty = CollectionUtil.isEmpty(list);
if (!empty) {
totalnum = list.size();
for (int i = 0; i < list.size(); i++) {
TerminalsAndStatusDto bean = list.get(i);
BigInteger lastheartbeat = bean.getLastHeartbeat();
boolean b = TerminalUtils.judgeTerminalStatus(lastheartbeat);
if (b) {
onlinenum++;
} else {
offlinenum++;
}
}
onlinePercent = XyNumberUtils.div(onlinenum, totalnum);
offlinePercent = XyNumberUtils.div(offlinenum, totalnum);
}
model.setOnlinePercent(onlinePercent);
model.setOfflinePercent(offlinePercent);
model.setOnlineNum(onlinenum);
model.setOfflineNum(offlinenum);
model.setTotalNum(totalnum);
return Asserts.success(model);
}
} }

@ -39,4 +39,17 @@ public interface TerminalAlarmService {
*/ */
ServiceBody<String> updateAlarmTypeList(UpdateTerminalAlarmParamsVo vo); ServiceBody<String> updateAlarmTypeList(UpdateTerminalAlarmParamsVo vo);
/**
*
* @return
*/
ServiceBody<TerminalWeekAlarmStatisticsModel> getWeekAlarmStatistics(WeekAlarmVo vo);
/**
*
*
* @param vo
* @return
*/
ServiceBody<TerminalTodayAlarmStatisticsModel> getTodayAlarmStatistics(WeekAlarmVo vo);
} }

@ -105,4 +105,11 @@ public interface TerminalService {
* @return * @return
*/ */
ServiceBody<TerminalStatusInfoModel> getLastTermInfo(Integer termId); ServiceBody<TerminalStatusInfoModel> getLastTermInfo(Integer termId);
/**
* 线
*
* @return
*/
ServiceBody<TerminalStatisticsModel> getTermStatistics();
} }

Loading…
Cancel
Save