feat:探测器报警信息

This commit is contained in:
nieziyan 2024-06-04 09:47:58 +08:00
parent 600c5235ec
commit e83c1d6199
6 changed files with 56 additions and 53 deletions

View File

@ -88,7 +88,7 @@ public class WebStatisticsController {
@GetMapping("findAlertSohPage")
@ApiOperation(value = "台站报警数据分页查询", notes = "台站报警数据分页查询")
public Result findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds,@DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,@DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
public Result findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, String startTime, String endTime){
return gardsSohDataService.findAlertSohPage(queryRequest, stationIds, startTime, endTime);
}

View File

@ -14,4 +14,6 @@ public class GardsAlertDataWeb extends GardsAlertData {
@TableField(exist = false)
private Integer no;
@TableField(exist = false)
private Integer category;
}

View File

@ -1,8 +1,12 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.entity.GardsAlertDataWeb;
public interface GardsAlertDataMapper extends BaseMapper<GardsAlertDataWeb> {
import java.util.List;
import java.util.Map;
public interface GardsAlertDataMapper extends BaseMapper<GardsAlertDataWeb> {
Page<GardsAlertDataWeb> page(Page<GardsAlertDataWeb> page, Map<String, Object> params);
}

View File

@ -0,0 +1,23 @@
<?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">
<mapper namespace="org.jeecg.modules.mapper.GardsAlertDataMapper">
<select id="page" resultType="org.jeecg.modules.entity.GardsAlertDataWeb">
SELECT
d.*, s.CATEGORY
FROM
ORIGINAL.GARDS_ALERT_DATA d
LEFT JOIN CONFIGURATION.GARDS_STATIONS s ON d.STATION_ID = s.STATION_ID
<where>
<if test="params.stationIds != null and params.stationIds.size() > 0">
d.STATION_ID IN
<foreach collection="params.stationIds" index="index" item="stationId" open="(" separator="," close=")">
#{stationId}
</foreach>
</if>
AND d.TIME BETWEEN TO_DATE(#{params.startTime}, 'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(#{params.endTime}, 'YYYY-MM-DD HH24:MI:SS')
</where>
ORDER BY d.TIME DESC
</select>
</mapper>

View File

@ -29,7 +29,7 @@ public interface IGardsSohDataService extends IService<GardsSohDataWeb> {
* @param endTime
* @return
*/
Result findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime);
Result findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, String startTime, String endTime);
/**
* 获取单个SOH对象

View File

@ -95,32 +95,9 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
}
@Override
public Result findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, Date startTime, Date endTime) {
try {
Result result = new Result();
if (Objects.isNull(stationIds)){
result.setResult(Collections.emptyList());
return result;
}
if (Objects.isNull(startTime)){
result.error500("The start time cannot be empty");
return result;
}
if (Objects.isNull(endTime)){
result.error500("The end time cannot be empty");
return result;
}
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
//获取redis中缓存的探测器信息
Map<Integer, String> detectorsMap = (Map<Integer, String>)redisUtil.get("detectorsMap");
Page<GardsAlertDataWeb> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
LambdaQueryWrapper<GardsAlertDataWeb> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(GardsAlertDataWeb::getStationId, stationIds);
queryWrapper.ge(GardsAlertDataWeb::getTime, startDate);
queryWrapper.le(GardsAlertDataWeb::getTime, endDate);
queryWrapper.orderByDesc(GardsAlertDataWeb::getTime);
Page<GardsAlertDataWeb> alertDataPage = gardsAlertDataMapper.selectPage(page, queryWrapper);
public Result<?> findAlertSohPage(QueryRequest queryRequest, Integer[] stationIds, String startTime, String endTime) {
Page<GardsAlertDataWeb> alertDataPage = gardsAlertDataMapper.page(null, null);
List<GardsAlertDataWeb> records = alertDataPage.getRecords();
if (CollUtil.isEmpty(records))
return Result.OK(alertDataPage);
@ -144,9 +121,6 @@ public class GardsSohDataServiceImpl extends ServiceImpl<GardsSohDataMapper, Gar
record.setAlertText(alertText);
}
return Result.OK(alertDataPage);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Override