Browse Source

完善F10告警,屏蔽处理

master
review512jwy@163.com 3 weeks ago
parent
commit
bb04628a32
  1. 5
      src/main/java/com/techsor/datacenter/sender/dao/DashboardAlertDao.java
  2. 22
      src/main/java/com/techsor/datacenter/sender/dao/DeviceDao.java
  3. 2
      src/main/java/com/techsor/datacenter/sender/entitiy/DeviceEntity.java
  4. 12
      src/main/java/com/techsor/datacenter/sender/service/F10Service.java
  5. 5
      src/main/java/com/techsor/datacenter/sender/service/IDataProcessService.java
  6. 3
      src/main/java/com/techsor/datacenter/sender/service/impl/DataProcessServiceImpl.java

5
src/main/java/com/techsor/datacenter/sender/dao/DashboardAlertDao.java

@ -167,8 +167,8 @@ public class DashboardAlertDao {
public Long insertAlertHistory(DynamodbEntity entity, int sourceType) { public Long insertAlertHistory(DynamodbEntity entity, int sourceType) {
String sql = "INSERT INTO alert_history (" + String sql = "INSERT INTO alert_history (" +
"device_id, receive_ts, source_type" + "device_id, receive_ts, source_type, block_flag " +
") VALUES (?, ?, ?)"; ") VALUES (?, ?, ?, ?)";
KeyHolder keyHolder = new GeneratedKeyHolder(); KeyHolder keyHolder = new GeneratedKeyHolder();
@ -177,6 +177,7 @@ public class DashboardAlertDao {
ps.setString(1, entity.getDeviceId()); ps.setString(1, entity.getDeviceId());
ps.setLong(2, entity.getReceive_ts()); ps.setLong(2, entity.getReceive_ts());
ps.setInt(3, sourceType); ps.setInt(3, sourceType);
ps.setLong(4, entity.getAlertBlock());
return ps; return ps;
}, keyHolder); }, keyHolder);

22
src/main/java/com/techsor/datacenter/sender/dao/DeviceDao.java

@ -153,7 +153,26 @@ public class DeviceDao {
return new ArrayList<>(); return new ArrayList<>();
} }
String sql = ""; String sql = "";
sql = "SELECT id,company_id,device_id,device_sn,type_id,space_id,building_id,device_name,project_id,floor_id,asset_id FROM device_info WHERE device_id='"+deviceId+"' and flag!=1"; sql = "SELECT\r\n"
+ " dinfo.id,\r\n"
+ " dinfo.company_id,\r\n"
+ " dinfo.device_id,\r\n"
+ " dinfo.device_sn,\r\n"
+ " dinfo.type_id,\r\n"
+ " bspace.space_id,\r\n"
+ " bbuilding.building_id,\r\n"
+ " dinfo.device_name,\r\n"
+ " dinfo.project_id,\r\n"
+ " bfloor.floor_id,\r\n"
+ " basset.class_big_id,\r\n"
+ " dinfo.asset_id\r\n"
+ "FROM device_info dinfo\r\n"
+ "INNER JOIN basic_monitoring_asset basset ON dinfo.asset_id = basset.equipment_id\r\n"
+ "INNER JOIN basic_space bspace ON bspace.space_id = basset.space_id\r\n"
+ "INNER JOIN basic_floor bfloor ON bfloor.floor_id = bspace.floor_id\r\n"
+ "INNER JOIN basic_building bbuilding ON bfloor.building_id = bbuilding.building_id\r\n"
+ "WHERE dinfo.flag != 1 AND basset.flag != 1 AND bspace.flag != 1 AND bfloor.flag != 1 AND bbuilding.flag != 1 AND\r\n"
+ "dinfo.device_id='"+deviceId+"'";
List<DeviceEntity> dataList = jdbcTemplate.query(sql, List<DeviceEntity> dataList = jdbcTemplate.query(sql,
(rs, rowNum) -> { (rs, rowNum) -> {
DeviceEntity item = new DeviceEntity(); DeviceEntity item = new DeviceEntity();
@ -168,6 +187,7 @@ public class DeviceDao {
item.setProjectId(rs.getLong("project_id")); item.setProjectId(rs.getLong("project_id"));
item.setFloorId(rs.getLong("floor_id")); item.setFloorId(rs.getLong("floor_id"));
item.setAssetId(rs.getLong("asset_id")); item.setAssetId(rs.getLong("asset_id"));
item.setBigClassId(rs.getLong("class_big_id"));
return item; return item;
}); });
return dataList; return dataList;

2
src/main/java/com/techsor/datacenter/sender/entitiy/DeviceEntity.java

@ -70,4 +70,6 @@ public class DeviceEntity implements Serializable {
private Long updatedTimestamp; private Long updatedTimestamp;
private Long bigClassId;
} }

12
src/main/java/com/techsor/datacenter/sender/service/F10Service.java

@ -7,6 +7,7 @@ import com.techsor.datacenter.sender.config.DataSourceContextHolder;
import com.techsor.datacenter.sender.dao.DashboardAlertDao; import com.techsor.datacenter.sender.dao.DashboardAlertDao;
import com.techsor.datacenter.sender.dao.DeviceDao; import com.techsor.datacenter.sender.dao.DeviceDao;
import com.techsor.datacenter.sender.dao.F10Dao; import com.techsor.datacenter.sender.dao.F10Dao;
import com.techsor.datacenter.sender.dto.DeviceInfoVO;
import com.techsor.datacenter.sender.entitiy.DeviceEntity; import com.techsor.datacenter.sender.entitiy.DeviceEntity;
import com.techsor.datacenter.sender.entitiy.DynamodbEntity; import com.techsor.datacenter.sender.entitiy.DynamodbEntity;
import com.techsor.datacenter.sender.entitiy.company.TopCompanyInfo; import com.techsor.datacenter.sender.entitiy.company.TopCompanyInfo;
@ -48,6 +49,8 @@ public class F10Service {
private DeviceDao deviceDao; private DeviceDao deviceDao;
@Autowired @Autowired
private DashboardAlertDao dashboardAlertDao; private DashboardAlertDao dashboardAlertDao;
@Autowired
private IDataProcessService dataProcessService;
@ -198,10 +201,19 @@ public class F10Service {
Long companyId = deviceEntity.get(0).getCompanyId(); Long companyId = deviceEntity.get(0).getCompanyId();
f10JournalLog.setCompanyId(companyId); f10JournalLog.setCompanyId(companyId);
DeviceInfoVO deviceInfoVO = new DeviceInfoVO();
deviceInfoVO.setDeviceId(deviceEntity.get(0).getDeviceId());
deviceInfoVO.setBuildingId(deviceEntity.get(0).getBuildingId());
deviceInfoVO.setBigClassId(deviceEntity.get(0).getBigClassId());
if (!isExpired){ if (!isExpired){
DynamodbEntity entity = new DynamodbEntity(); DynamodbEntity entity = new DynamodbEntity();
entity.setDeviceId(f10JournalLog.getDeviceId()); entity.setDeviceId(f10JournalLog.getDeviceId());
if ("1".equals(f10JournalLog.getInstructionFlag())){ if ("1".equals(f10JournalLog.getInstructionFlag())){
dataProcessService.setAlertBlock(deviceInfoVO);
entity.setAlertBlock(deviceInfoVO.getAlertBlock());
entity.setReceive_ts(currentTs); entity.setReceive_ts(currentTs);
Long dbId = dashboardAlertDao.insertAlertHistory(entity, 2); Long dbId = dashboardAlertDao.insertAlertHistory(entity, 2);
f10JournalLog.setAlertHistoryId(dbId); f10JournalLog.setAlertHistoryId(dbId);

5
src/main/java/com/techsor/datacenter/sender/service/IDataProcessService.java

@ -1,5 +1,6 @@
package com.techsor.datacenter.sender.service; package com.techsor.datacenter.sender.service;
import com.techsor.datacenter.sender.dto.DeviceInfoVO;
import com.techsor.datacenter.sender.entitiy.DynamodbEntity; import com.techsor.datacenter.sender.entitiy.DynamodbEntity;
import com.techsor.datacenter.sender.entitiy.ResultDeviceIdEntity; import com.techsor.datacenter.sender.entitiy.ResultDeviceIdEntity;
@ -20,5 +21,7 @@ public interface IDataProcessService {
void processZAIoTData(ResultDeviceIdEntity entity); void processZAIoTData(ResultDeviceIdEntity entity);
void minuteLevelStorage(DynamodbEntity baseTransDataEntity) throws Exception; void setAlertBlock(DeviceInfoVO deviceInfoVO);
void minuteLevelStorage(DynamodbEntity baseTransDataEntity) throws Exception;
} }

3
src/main/java/com/techsor/datacenter/sender/service/impl/DataProcessServiceImpl.java

@ -695,7 +695,8 @@ public class DataProcessServiceImpl implements IDataProcessService {
//更新 //更新
} }
private void setAlertBlock(DeviceInfoVO deviceInfoVO) { @Override
public void setAlertBlock(DeviceInfoVO deviceInfoVO) {
if (deviceInfoVO != null && deviceInfoVO.getBuildingId() != null) { if (deviceInfoVO != null && deviceInfoVO.getBuildingId() != null) {
List<BlockConfigDTO> blockConfigs = dashboardBlockConfigDao List<BlockConfigDTO> blockConfigs = dashboardBlockConfigDao
.queryActiveBlockConfigsByBuildingId(deviceInfoVO.getBuildingId()); .queryActiveBlockConfigsByBuildingId(deviceInfoVO.getBuildingId());

Loading…
Cancel
Save