fix:依赖补全

update:接口测试修改
This commit is contained in:
nieziyan 2023-06-16 20:12:38 +08:00
parent f0d2d5f108
commit fa2366b8aa
10 changed files with 83 additions and 61 deletions

View File

@ -16,20 +16,20 @@ public class AlarmLogController {
@Autowired @Autowired
private IAlarmLogService alarmLogService; private IAlarmLogService alarmLogService;
@ApiOperation("报警日志量总览-柱状图") @ApiOperation("报警日志量总览-柱状图")
@GetMapping("viewAll") @PostMapping("viewAll")
public Result viewAll(@RequestBody AlarmVo alarmVo){ return alarmLogService.viewAll(alarmVo); } public Result viewAll(@RequestBody AlarmVo alarmVo){ return alarmLogService.viewAll(alarmVo); }
@ApiOperation("分页查询报警日志信息") @ApiOperation("分页查询报警日志信息")
@GetMapping("findPage") @PostMapping("findPage")
public Result findPage(@RequestBody AlarmVo alarmVo){ public Result findPage(@RequestBody AlarmVo alarmVo){
return alarmLogService.findPage(alarmVo); return alarmLogService.findPage(alarmVo);
} }
@ApiOperation("各类型报警量统计-饼图") @ApiOperation("各类型报警量统计-饼图")
@GetMapping("typeAlarms") @PostMapping("typeAlarms")
public Result typeAlarms(@RequestBody AlarmVo alarmVo){ public Result typeAlarms(@RequestBody AlarmVo alarmVo){
return alarmLogService.typeAlarms(alarmVo); return alarmLogService.typeAlarms(alarmVo);
} }
@ApiOperation("报警规则top5-柱状图") @ApiOperation("报警规则top5-柱状图")
@GetMapping("ruleTop") @PostMapping("ruleTop")
public Result ruleTop5(@RequestBody AlarmVo alarmVo){ public Result ruleTop5(@RequestBody AlarmVo alarmVo){
return alarmLogService.ruleTop5(alarmVo); return alarmLogService.ruleTop5(alarmVo);
} }

View File

@ -13,9 +13,7 @@ import java.util.Map;
public interface AlarmLogMapper extends BaseMapper<AlarmLog> { public interface AlarmLogMapper extends BaseMapper<AlarmLog> {
List<Date> oneDay(Map<String,Object> params); List<Date> rangeDay(Map<String,Object> params);
List<Date> oneMoreDay(Map<String,Object> params);
List<AlarmHistory> findPage(Map<String,Object> params); List<AlarmHistory> findPage(Map<String,Object> params);
List<TypeDto> typeAlarms(Map<String,Object> params); List<TypeDto> typeAlarms(Map<String,Object> params);

View File

@ -1,6 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mapper.AlarmLogMapper"> <mapper namespace="org.jeecg.modules.mapper.AlarmLogMapper">
<select id="rangeDay" parameterType="Map" resultType="Date">
SELECT
l.alarm_start_date
FROM
alarm_log l
INNER JOIN alarm_rule r ON l.rule_id = r.ID
<where>
<if test="type != null and type != ''">
r.source_type = #{type}
</if>
<if test="startDate != null and startDate != ''">
AND l.alarm_start_date &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND l.alarm_start_date &lt;= #{endDate}
</if>
</where>
</select>
<select id="findPage" parameterType="Map" resultType="org.jeecg.modules.entity.AlarmHistory"> <select id="findPage" parameterType="Map" resultType="org.jeecg.modules.entity.AlarmHistory">
SELECT SELECT
* *
@ -37,7 +55,9 @@
AND alarm_start_date &lt;= #{endDate} AND alarm_start_date &lt;= #{endDate}
</if> </if>
</where> </where>
LIMIT #{pageStart}, #{pageSize} <if test="pageFlag == null">
LIMIT #{pageSize} OFFSET #{pageStart}
</if>
</select> </select>
<select id="typeAlarms" parameterType="Map" resultType="org.jeecg.modules.dto.TypeDto"> <select id="typeAlarms" parameterType="Map" resultType="org.jeecg.modules.dto.TypeDto">
SELECT SELECT
@ -88,37 +108,4 @@
</where> </where>
ORDER BY l.ruleCount DESC ORDER BY l.ruleCount DESC
</select> </select>
<select id="oneDay" parameterType="Map" resultType="Date">
SELECT
l.alarm_start_date
FROM
alarm_log l
INNER JOIN alarm_rule r ON l.rule_id = r.ID
<where>
<if test="type != null and type != ''">
r.source_type = #{type}
</if>
<if test="startDate != null and startDate != ''">
AND l.alarm_start_date = #{startDate}
</if>
</where>
</select>
<select id="oneMoreDay" parameterType="Map" resultType="Date">
SELECT
l.alarm_start_date
FROM
alarm_log l
INNER JOIN alarm_rule r ON l.rule_id = r.ID
<where>
<if test="type != null and type != ''">
r.source_type = #{type}
</if>
<if test="startDate != null and startDate != ''">
AND l.alarm_start_date &gt;= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND l.alarm_start_date &lt;= #{endDate}
</if>
</where>
</select>
</mapper> </mapper>

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.service.impl; package org.jeecg.modules.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -37,11 +38,26 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
public Result viewAll(AlarmVo alarmVo) { public Result viewAll(AlarmVo alarmVo) {
String startDate = alarmVo.getStartDate(); String startDate = alarmVo.getStartDate();
String endDate = alarmVo.getEndDate(); String endDate = alarmVo.getEndDate();
// 拼接日期为合理的日期+时间范围
alarmVo.setStartDate(startDate + " 00:00:00");
alarmVo.setEndDate(endDate + " 23:59:59");
// 定义返回结果
Set<String> xData = new HashSet<>();
Collection<Integer> YData = new ArrayList<>();
Map<String,Object> result = new HashMap<>();
// 转换参数 数据查询
Map<String, Object> params = BeanUtil.beanToMap(alarmVo); Map<String, Object> params = BeanUtil.beanToMap(alarmVo);
List<Date> allDate; List<Date> allDate = baseMapper.rangeDay(params);
/* 选择日期为同一天 按照小时划分 0-23小时 */ // 查询数据为空则直接返回空集合
if (CollUtil.isEmpty(allDate)){
result.put("xData",xData);
result.put("yData",YData);
return Result.OK(result);
}
// 分情况处理 1.按小时统计 2.按天统计
/* 1.选择日期为同一天 按照小时划分 0-23小时 */
if (startDate.equals(endDate)){ if (startDate.equals(endDate)){
allDate = baseMapper.oneDay(params);
Map<Integer, List<Date>> groupTime = allDate.stream() Map<Integer, List<Date>> groupTime = allDate.stream()
.sorted(Comparator.comparing(Date::getHours)) .sorted(Comparator.comparing(Date::getHours))
.collect(Collectors.groupingBy(Date::getHours)); .collect(Collectors.groupingBy(Date::getHours));
@ -55,17 +71,14 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
} }
} }
// 返回x轴和y轴数据 // 返回x轴和y轴数据
Set<String> xData = statistic.keySet(); xData = statistic.keySet();
Collection<Integer> YData = statistic.values(); YData = statistic.values();
Map<String,Object> result = new HashMap<>();
result.put("xData",xData); result.put("xData",xData);
result.put("yData",YData); result.put("yData",YData);
return Result.OK(result); return Result.OK(result);
} }
/* 选择日期不是同一天 按照天划分(可以跨月选择,但不包括跨年) */ /* 2.选择日期不是同一天 按照天划分(可以跨月选择,但不包括跨年) */
else { else {
allDate = baseMapper.oneMoreDay(params);
Map<String,Integer> statistic = new HashMap<>(); Map<String,Integer> statistic = new HashMap<>();
// 通过mounth分组 // 通过mounth分组
Map<Integer, List<Date>> groupMounth = allDate.stream() Map<Integer, List<Date>> groupMounth = allDate.stream()
@ -102,16 +115,16 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
return dateStr; return dateStr;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
// 将startDate和endDate中没有预警信息的day设置为0 // startDate和endDate范围内无报警信息
// 的日期(哪一天),将其报警数量设置为0
for (String dateStr : allDateStr) { for (String dateStr : allDateStr) {
if (!allDateStr.contains(dateStr)){ if (!allDateStr.contains(dateStr)){
statistic.put(dateStr,0); statistic.put(dateStr,0);
} }
} }
// 返回x轴和y轴数据 // 返回x轴和y轴数据
Set<String> xData = statistic.keySet(); xData = statistic.keySet();
Collection<Integer> YData = statistic.values(); YData = statistic.values();
Map<String,Object> result = new HashMap<>();
result.put("xData",xData); result.put("xData",xData);
result.put("yData",YData); result.put("yData",YData);
return Result.OK(result); return Result.OK(result);
@ -134,8 +147,10 @@ public class AlarmLogServiceImpl extends ServiceImpl<AlarmLogMapper, AlarmLog> i
List<AlarmHistory> alarmHistories = baseMapper.findPage(params); List<AlarmHistory> alarmHistories = baseMapper.findPage(params);
// 当前页数据 // 当前页数据
page.setRecords(alarmHistories); page.setRecords(alarmHistories);
// 数据总条数 // 获取数据总条数(经过查询条件过滤后的)
page.setTotal(this.count()); params.put("pageFlag","noPage");
Integer total = baseMapper.findPage(params).size();
page.setTotal(total);
return Result.OK(page); return Result.OK(page);
} }

View File

@ -11,4 +11,6 @@ public class AlarmVo extends QueryRequest implements Serializable {
private String startDate; private String startDate;
private String endDate; private String endDate;
private Integer pageStart; private Integer pageStart;
// 标记根据条件查询但不进行分页
private String pageFlag;
} }

View File

@ -88,7 +88,8 @@ public class LoginController {
//update-begin--Author:scott Date:20190805 for暂时注释掉密码加密逻辑有点问题 //update-begin--Author:scott Date:20190805 for暂时注释掉密码加密逻辑有点问题
//update-begin-author:taoyan date:20190828 for:校验验证码 //update-begin-author:taoyan date:20190828 for:校验验证码
String captcha = sysLoginModel.getCaptcha();
/* String captcha = sysLoginModel.getCaptcha();
if(captcha==null){ if(captcha==null){
result.error500("验证码无效"); result.error500("验证码无效");
return result; return result;
@ -107,7 +108,7 @@ public class LoginController {
// 改成特殊的code 便于前端判断 // 改成特殊的code 便于前端判断
result.setCode(HttpStatus.PRECONDITION_FAILED.value()); result.setCode(HttpStatus.PRECONDITION_FAILED.value());
return result; return result;
} }*/
//update-end-author:taoyan date:20190828 for:校验验证码 //update-end-author:taoyan date:20190828 for:校验验证码
//1. 校验用户是否有效 //1. 校验用户是否有效
@ -135,7 +136,7 @@ public class LoginController {
//用户登录信息 //用户登录信息
userInfo(sysUser, result); userInfo(sysUser, result);
//update-begin--Author:liusq Date:20210126 for登录成功删除redis中的验证码 //update-begin--Author:liusq Date:20210126 for登录成功删除redis中的验证码
redisUtil.del(realKey); //redisUtil.del(realKey);
//update-begin--Author:liusq Date:20210126 for登录成功删除redis中的验证码 //update-begin--Author:liusq Date:20210126 for登录成功删除redis中的验证码
redisUtil.del(CommonConstant.LOGIN_FAIL + username); redisUtil.del(CommonConstant.LOGIN_FAIL + username);
LoginUser loginUser = new LoginUser(); LoginUser loginUser = new LoginUser();

View File

@ -12,8 +12,12 @@
<artifactId>jeecg-abnormal-alarm-start</artifactId> <artifactId>jeecg-abnormal-alarm-start</artifactId>
<dependencies> <dependencies>
<!-- jeecg-system-cloud-api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
</dependency>
<!-- jeecg-module-abnormal-alarm模块 -->
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-abnormal-alarm</artifactId> <artifactId>jeecg-module-abnormal-alarm</artifactId>

View File

@ -12,6 +12,11 @@
<artifactId>jeecg-log-manage-start</artifactId> <artifactId>jeecg-log-manage-start</artifactId>
<dependencies> <dependencies>
<!-- jeecg-system-cloud-api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-log-manage</artifactId> <artifactId>jeecg-module-log-manage</artifactId>

View File

@ -12,6 +12,11 @@
<artifactId>jeecg-station-operation-start</artifactId> <artifactId>jeecg-station-operation-start</artifactId>
<dependencies> <dependencies>
<!-- jeecg-system-cloud-api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-station-operation</artifactId> <artifactId>jeecg-module-station-operation</artifactId>

View File

@ -12,6 +12,11 @@
<artifactId>jeecg-web-statistics-start</artifactId> <artifactId>jeecg-web-statistics-start</artifactId>
<dependencies> <dependencies>
<!-- jeecg-system-cloud-api -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-system-cloud-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.jeecgframework.boot</groupId> <groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-module-web-statistics</artifactId> <artifactId>jeecg-module-web-statistics</artifactId>