Commit 8d87161f authored by zhangsen's avatar zhangsen

td相关

parent 0b90ed8d
......@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvHealthIndexDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -33,4 +36,10 @@ public interface IdxBizPvHealthIndexMapper extends BaseMapper<IdxBizPvHealthInde
List<Map<String,Object>> selectPointByANALYSISTYPE(String STATION, String HEALTHLEVEL,String EQUIPMENTNAME,String POINTNAME,String SUBARRAY,String startTime,String endTime);
int saveBatchHealthIndexLatestInfo(@Param("list") List<FanHealthIndex> list);
void deleteAllDataByTableName(@Param("tableName") String tableName, @Param("analysisType") String analysisType);
int saveBatchHealthIndexLatestInfoPv(@Param("list") List<PvHealthIndex> list);
}
......@@ -150,6 +150,10 @@ public class CommonServiceImpl {
private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
private IdxBizPvHealthIndexMapper idxFanHealthIndexMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper;
......@@ -1733,7 +1737,7 @@ public class CommonServiceImpl {
*/
@Async
public void insertFanDataTDEngine(ArrayList<FanHealthIndex> fanHealthIndices, String recDate, String analysisType) {
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按时刻");
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", analysisType);
// 按时刻 - 测点插入
ArrayList<FanHealthIndex> newList = new ArrayList<>();
for (int i = 0; i < fanHealthIndices.size(); i++) {
......@@ -1742,7 +1746,7 @@ public class CommonServiceImpl {
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexList(newList, "fan_health_index_moment", analysisType);
fanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "fan_health_index_latest_data");
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
......@@ -2004,7 +2008,7 @@ public class CommonServiceImpl {
@Async
public void insertPvDataTDEngine(ArrayList<PvHealthIndex> pvHealthIndices, String recDate, String analysisType) {
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", analysisType);
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", analysisType);
// 按时刻 - 测点插入
ArrayList<PvHealthIndex> newList = new ArrayList<>();
......@@ -2014,7 +2018,7 @@ public class CommonServiceImpl {
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, "pv_health_index_moment", analysisType);
pvHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "fan_health_index_latest_data");
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfoPv(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
......
......@@ -6,6 +6,7 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
......@@ -34,6 +35,10 @@ public class TdengineTimeServiceImpl {
private FanHealthIndexMapper fanHealthIndexMapper;
@Autowired
private IdxBizPvHealthIndexMapper idxFanHealthIndexMapper;
@Autowired
private PvHealthIndexMapper pvHealthIndexMapper;
@Autowired
......@@ -78,7 +83,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) {
return;
}
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按小时");
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按小时");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00");
// 8小时 + 59分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN);
......@@ -112,7 +117,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) {
return;
}
fanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按天");
idxFanHealthIndexMapper.deleteAllDataByTableName("fan_health_index_latest_data", "按天");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
List<IdxBizFanHealthLevel> levelList = idxBizFanHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizFanHealthLevel>().eq(IdxBizFanHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
......@@ -166,7 +171,7 @@ public class TdengineTimeServiceImpl {
if (500 == newList.size() || i == fanHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
fanHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType);
fanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "fan_health_index_latest_data");
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
......@@ -203,7 +208,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) {
return;
}
fanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按小时");
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按小时");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd HH:00:00");
// 8小时 + 59分钟
String startTime = DateUtils.dateFormat(DateUtils.dateAddMinutes(new Date(), -541), DateUtils.DATE_TIME_PATTERN);
......@@ -237,7 +242,7 @@ public class TdengineTimeServiceImpl {
if (!openHealth) {
return;
}
fanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按天");
idxFanHealthIndexMapper.deleteAllDataByTableName("pv_health_index_latest_data", "按天");
String recDate = DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00");
List<IdxBizPvHealthLevel> levelList = idxBizPvHealthLevelMapper.selectList(new LambdaQueryWrapper<IdxBizPvHealthLevel>().eq(IdxBizPvHealthLevel::getAnalysisObjType, "测点").last("limit 4"));
String startTime = DateUtils.dateFormat(DateUtils.dateAddHours(new Date(), -32), DateUtils.DATE_TIME_PATTERN);
......@@ -290,7 +295,7 @@ public class TdengineTimeServiceImpl {
if (500 == newList.size() || i == pvHealthIndices.size() - 1) { //载体list达到要求,进行批量操作
//调用批量插入
pvHealthIndexMapper.saveBatchHealthIndexList(newList, tableName, analysisType);
pvHealthIndexMapper.saveBatchHealthIndexLatestInfo(newList, "pv_health_index_latest_data");
idxFanHealthIndexMapper.saveBatchHealthIndexLatestInfoPv(newList);
newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
}
}
......
......@@ -27,9 +27,9 @@ public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
int saveBatchHealthIndexList(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType);
int saveBatchHealthIndexLatestInfo(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName);
void deleteAllDataByTableName(@Param("tableName") String tableName, @Param("analysisType") String analysisType);
// int saveBatchHealthIndexLatestInfo(@Param("list") List<FanHealthIndex> list, @Param("tableName") String tableName);
//
// void deleteAllDataByTableName(@Param("tableName") String tableName, @Param("analysisType") String analysisType);
/**
* 测点
......
......@@ -31,7 +31,7 @@ public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
int saveBatchHealthIndexList(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName, @Param("analysisType") String analysisType);
int saveBatchHealthIndexLatestInfo(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName);
// int saveBatchHealthIndexLatestInfo(@Param("list") List<PvHealthIndex> list, @Param("tableName") String tableName);
List<PvHealthIndex> getInfoListByGroupByCdPv(@Param("startTime") String startTime,
@Param("tableName") String tableName,
......
......@@ -61,7 +61,7 @@
SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
idx_biz_fan_health_index
fan_health_index_latest_data
<where>
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
......@@ -95,7 +95,7 @@
SELECT
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
idx_biz_pv_health_index
pv_health_index_latest_data
<where>
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
AND ANALYSIS_TYPE = '按天'
......@@ -1367,7 +1367,7 @@
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION
FROM idx_biz_fan_health_index
FROM fan_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
......@@ -1388,7 +1388,7 @@
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
STATION AS STATION
FROM idx_biz_pv_health_index
FROM pv_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '场站'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
......@@ -1416,7 +1416,7 @@
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS equipmentName
FROM idx_biz_fan_health_index
FROM fan_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '设备'
......@@ -1438,7 +1438,7 @@
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUBARRAY AS equipmentName
FROM idx_biz_pv_health_index
FROM pv_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '子阵'
......@@ -1471,7 +1471,7 @@
FROM (
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
SUB_SYSTEM AS subSystem
FROM idx_biz_fan_health_index
FROM fan_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '子系统'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
......@@ -1492,7 +1492,7 @@
(
SELECT IFNULL(AVG(HEALTH_INDEX), 100) AS avgHealthIndex,
EQUIPMENT_NAME AS subSystem
FROM idx_biz_pv_health_index
FROM pv_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '设备'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
......@@ -1522,7 +1522,7 @@
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_fan_health_index
FROM fan_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
......@@ -1544,7 +1544,7 @@
(
SELECT IFNULL(HEALTH_INDEX, 100) AS healthIndex,
concat(STATION, '_', INDEX_ADDRESS) as gatewayIndexAddress
FROM idx_biz_pv_health_index
FROM pv_health_index_latest_data
<where>
ANALYSIS_OBJ_TYPE = '测点'
<if test="analysisType == '按天' or analysisType == null or analysisType == ''">
......
......@@ -335,4 +335,112 @@
</select>
<insert id="saveBatchHealthIndexLatestInfo">
insert into
fan_health_index_latest_data
(
`REC_DATE`,
`ANALYSIS_OBJ_TYPE`,
`ANALYSIS_OBJ_SEQ`,
`WEIGTH`,
`HEALTH_INDEX`,
`HEALTH_LEVEL`,
`ANALYSIS_TYPE`,
`ANALYSIS_START_TIME`,
`ANALYSIS_END_TIME`,
`ARAE`,
`STATION`,
`SUB_SYSTEM`,
`NUMBER`,
`EQUIPMENT_NAME`,
`GATEWAY_ID`,
`INDEX_ADDRESS`,
`ANOMALY`,
`POINT_NAME`,
`ANALYSIS_TIME`,
`KKS`
)
values
<foreach collection="list" separator="," item="item" index="index">
(
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisType, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subSystem, jdbcType=VARCHAR},
#{item.number, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</insert>
<delete id="deleteAllDataByTableName">
delete from ${tableName} where analysis_type = #{analysisType}
</delete>
<insert id="saveBatchHealthIndexLatestInfoPv">
insert into pv_health_index_latest_data
(
`REC_DATE`,
`ANALYSIS_OBJ_TYPE`,
`ANALYSIS_OBJ_SEQ`,
`WEIGTH`,
`HEALTH_INDEX`,
`HEALTH_LEVEL`,
`ANALYSIS_TYPE`,
`ANALYSIS_START_TIME`,
`ANALYSIS_END_TIME`,
`ARAE`,
`STATION`,
`SUBARRAY`,
`MANUFACTURER`,
`DEVICE_TYPE`,
`GATEWAY_ID`,
`INDEX_ADDRESS`,
`EQUIPMENT_NAME`,
`ANOMALY`,
`POINT_NAME`,
`ANALYSIS_TIME`,
`KKS`
)
values
<foreach collection="list" separator="," item="item" index="index">
(
#{item.recDate, jdbcType=VARCHAR},
#{item.analysisObjType, jdbcType=VARCHAR},
#{item.analysisObjSeq, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.healthIndex, jdbcType=FLOAT},
#{item.healthLevel, jdbcType=VARCHAR},
#{item.analysisType, jdbcType=VARCHAR},
#{item.analysisStartTime, jdbcType=VARCHAR},
#{item.analysisEndTime, jdbcType=VARCHAR},
#{item.area, jdbcType=VARCHAR},
#{item.station, jdbcType=VARCHAR},
#{item.subarray, jdbcType=VARCHAR},
#{item.manufacturer, jdbcType=VARCHAR},
#{item.deviceType, jdbcType=VARCHAR},
#{item.gatewayId, jdbcType=VARCHAR},
#{item.indexAddress, jdbcType=VARCHAR},
#{item.equipmentName, jdbcType=VARCHAR},
#{item.anomaly, jdbcType=FLOAT},
#{item.pointName, jdbcType=VARCHAR},
#{item.analysisTime, jdbcType=VARCHAR},
#{item.kks, jdbcType=VARCHAR}
)
</foreach>
</insert>
</mapper>
......@@ -224,6 +224,6 @@
</select>
<delete id="deleteAllDataByTableName">
delete * from ${tableName} where analysis_type = #{analysisType}
delete from ${tableName} where analysis_type = #{analysisType}
</delete>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment