Compare commits

..

No commits in common. "7908eba1358828cbb3f7f3e5efa0bcf3874fe7cf" and "ba7ff2a5d16c0012b335c1b666f9871f732d97f3" have entirely different histories.

8 changed files with 43 additions and 13 deletions

View File

@ -10,7 +10,6 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* 附件

View File

@ -33,7 +33,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -204,8 +203,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceRepository, Device> imp
.directCount(productRepo.selectCount(new LambdaQueryWrapper<Product>().eq(Product::getLink, Product.LinkType.HTTP)))
.gatewayCount(productRepo.selectCount(new LambdaQueryWrapper<Product>().eq(Product::getLink, Product.LinkType.TCP)))
.gatewaySubCount(productRepo.selectCount(new LambdaQueryWrapper<Product>().eq(Product::getLink, Product.LinkType.MQTT)))
.warningCount(baseMapper.selectCount(new LambdaQueryWrapper<Device>().eq(Device::getDeviceState, false)))
.todayWarningCount(baseMapper.selectCount(new LambdaQueryWrapper<Device>().eq(Device::getDeviceState, false).between(Device::getCreateTime, LocalDateTime.now().withHour(0).withMinute(0).withSecond(0), LocalDateTime.now())))
.build();
}

View File

@ -59,13 +59,4 @@ public class DeviceStatusVo {
*/
public Long gatewaySubCount;
/**
* 报警数
*/
public Long warningCount;
/**
* 今日新增
*/
public Long todayWarningCount;
}

View File

@ -110,12 +110,22 @@ public class DeviceVo {
*/
public String iconId;
/**
* 设备图标附件
*/
public Attachment icon;
/**
* 设备预览图附件ID
*/
public String previewId;
/**
* 设备预览图附件
*/
public Attachment preview;
/**
* 所属产品ID
*/

View File

@ -19,4 +19,13 @@ public class RecordDataStatusVo {
*/
public Long dataCount;
/**
* 告警总数
*/
private Long warningCount;
/**
* 今日新增
*/
private Long todayWarningCount;
}

View File

@ -12,6 +12,14 @@ import java.util.List;
* @author zhuang
*/
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);
}

View File

@ -72,7 +72,11 @@ public class RecordDataServiceImpl extends ServiceImpl<RecordDataRepository, Rec
*/
@Override
public RecordDataStatusVo recordDataStatus() {
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
return RecordDataStatusVo.builder()
.warningCount(baseMapper.countWarnings())
.todayWarningCount(baseMapper.countTodayWarnings(todayStart))
.recordCount(baseMapper.selectCount(new LambdaQueryWrapper<>()))
.dataCount(baseMapper.selectCount(new LambdaQueryWrapper<RecordData>().isNotNull(RecordData::getContent)))
.build();

View File

@ -36,6 +36,18 @@
<result column="update_time" jdbcType="DATE" property="updateTime"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<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"
columnPrefix="param_">
<id column="id" property="id"/>