refactor(iot): 重构设备和记录相关代码
- 移除 Attachment 类的冗余导入- 删除 DeviceMapper.xml 中的冗余关联映射 - 更新 DeviceStatusVo 和 DeviceVo 中的字段 - 移除 RecordDataRepository 中的告警统计相关方法- 更新 RecordDataServiceImpl 中的 recordDataStatus 方法 - 删除 RecordDataStatusVo 中的告警统计字段
This commit is contained in:
parent
ba7ff2a5d1
commit
be5c66378d
@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 附件
|
* 附件
|
||||||
|
@ -59,4 +59,13 @@ public class DeviceStatusVo {
|
|||||||
*/
|
*/
|
||||||
public Long gatewaySubCount;
|
public Long gatewaySubCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报警数
|
||||||
|
*/
|
||||||
|
public Long warningCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日新增
|
||||||
|
*/
|
||||||
|
public Long todayWarningCount;
|
||||||
}
|
}
|
||||||
|
@ -110,22 +110,12 @@ public class DeviceVo {
|
|||||||
*/
|
*/
|
||||||
public String iconId;
|
public String iconId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备图标附件
|
|
||||||
*/
|
|
||||||
public Attachment icon;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备预览图附件ID
|
* 设备预览图附件ID
|
||||||
*/
|
*/
|
||||||
public String previewId;
|
public String previewId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备预览图附件
|
|
||||||
*/
|
|
||||||
public Attachment preview;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属产品ID
|
* 所属产品ID
|
||||||
*/
|
*/
|
||||||
|
@ -19,13 +19,4 @@ public class RecordDataStatusVo {
|
|||||||
*/
|
*/
|
||||||
public Long dataCount;
|
public Long dataCount;
|
||||||
|
|
||||||
/**
|
|
||||||
* 告警总数
|
|
||||||
*/
|
|
||||||
private Long warningCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 今日新增
|
|
||||||
*/
|
|
||||||
private Long todayWarningCount;
|
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,6 @@ import java.util.List;
|
|||||||
* @author zhuang
|
* @author zhuang
|
||||||
*/
|
*/
|
||||||
public interface RecordDataRepository extends BaseMapper<RecordData> {
|
public interface RecordDataRepository extends BaseMapper<RecordData> {
|
||||||
@Select("SELECT COUNT(*) FROM iot_record_data WHERE content::jsonb->>'warning' IS NOT NULL AND (content::jsonb->>'warning')::int & 1 = 0 AND ((content::jsonb->>'warning')::int & ~1) > 0")
|
|
||||||
long countWarnings();
|
|
||||||
|
|
||||||
@Select("SELECT COUNT(*) FROM iot_record_data WHERE content::jsonb->>'warning' IS NOT NULL AND ((content::jsonb->>'warning')::int & 1 = 0) AND ((content::jsonb->>'warning')::int & ~1) > 0 AND record_time >= #{todayStart}")
|
|
||||||
long countTodayWarnings(@Param("todayStart") LocalDateTime todayStart);
|
|
||||||
|
|
||||||
@Select("SELECT COUNT(*) FROM iot_record_data WHERE content::jsonb->>'warning' IS NOT NULL AND (content::jsonb->>'warning')::int & #{bitPosition} = #{bitPosition}")
|
|
||||||
long countWarningsByBit(@Param("bitPosition") int bitPosition);
|
|
||||||
|
|
||||||
List<RecordData> selectByClientId(@Param("clientId") String clientId);
|
List<RecordData> selectByClientId(@Param("clientId") String clientId);
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,7 @@ public class RecordDataServiceImpl extends ServiceImpl<RecordDataRepository, Rec
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public RecordDataStatusVo recordDataStatus() {
|
public RecordDataStatusVo recordDataStatus() {
|
||||||
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
|
|
||||||
|
|
||||||
return RecordDataStatusVo.builder()
|
return RecordDataStatusVo.builder()
|
||||||
.warningCount(baseMapper.countWarnings())
|
|
||||||
.todayWarningCount(baseMapper.countTodayWarnings(todayStart))
|
|
||||||
.recordCount(baseMapper.selectCount(new LambdaQueryWrapper<>()))
|
.recordCount(baseMapper.selectCount(new LambdaQueryWrapper<>()))
|
||||||
.dataCount(baseMapper.selectCount(new LambdaQueryWrapper<RecordData>().isNotNull(RecordData::getContent)))
|
.dataCount(baseMapper.selectCount(new LambdaQueryWrapper<RecordData>().isNotNull(RecordData::getContent)))
|
||||||
.build();
|
.build();
|
||||||
|
@ -36,18 +36,6 @@
|
|||||||
<result column="update_time" jdbcType="DATE" property="updateTime"/>
|
<result column="update_time" jdbcType="DATE" property="updateTime"/>
|
||||||
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
||||||
<result column="enabled" jdbcType="BOOLEAN" property="enabled"/>
|
<result column="enabled" jdbcType="BOOLEAN" property="enabled"/>
|
||||||
<association property="icon" javaType="com.zsc.edu.gateway.modules.attachment.entity.Attachment"
|
|
||||||
autoMapping="true"
|
|
||||||
columnPrefix="icon_">
|
|
||||||
<id column="id" property="id"/>
|
|
||||||
<result column="file_name" property="fileName"/>
|
|
||||||
</association>
|
|
||||||
<association property="preview" javaType="com.zsc.edu.gateway.modules.attachment.entity.Attachment"
|
|
||||||
autoMapping="true"
|
|
||||||
columnPrefix="preview_">
|
|
||||||
<id column="id" property="id"/>
|
|
||||||
<result column="file_name" property="fileName"/>
|
|
||||||
</association>
|
|
||||||
<collection property="params" ofType="com.zsc.edu.gateway.modules.iot.tsl.entity.Param" autoMapping="true"
|
<collection property="params" ofType="com.zsc.edu.gateway.modules.iot.tsl.entity.Param" autoMapping="true"
|
||||||
columnPrefix="param_">
|
columnPrefix="param_">
|
||||||
<id column="id" property="id"/>
|
<id column="id" property="id"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user