mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
添加统计字段
This commit is contained in:
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
select gen_random_uuid()::text as id,
|
||||
d.organization_id,
|
||||
d.name,
|
||||
d.product_id as product_id,
|
||||
'' as code,
|
||||
'' as remarks,
|
||||
0 as sort_key,
|
||||
@@ -78,16 +79,17 @@ select gen_random_uuid()::text as id,
|
||||
array_agg(d.id) as ids
|
||||
from ((select 1.0 / count(1) over (partition by date_trunc('day', date)) as xx , *
|
||||
from t_coal_washing_daily_analysis)) d
|
||||
group by d.organization_id, d.name, date_trunc('month', d.date)
|
||||
group by d.organization_id, d.name, d.product_id, date_trunc('month', d.date)
|
||||
|
||||
""")
|
||||
|
||||
@jakarta.persistence.Table(indexes = @jakarta.persistence.Index(name ="idx_coal_washing_month_report_org_id", columnList = "organization_id"))
|
||||
//@jakarta.persistence.Table(indexes = @jakarta.persistence.Index(name ="idx_coal_washing_month_report_org_id", columnList = "organization_id"))
|
||||
|
||||
public class CoalWashingMonthReportEntity extends OrgCommonEntity {
|
||||
|
||||
@Comment("日期")
|
||||
private LocalDate date;
|
||||
private String productId;
|
||||
private String remark1;
|
||||
private String remark2;
|
||||
private String remark3;
|
||||
|
||||
@@ -7,6 +7,9 @@ import cn.lihongjie.coal.pojoProcessor.DictTranslate;
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class MeterDto extends OrgCommonDto {
|
||||
@@ -23,4 +26,14 @@ public class MeterDto extends OrgCommonDto {
|
||||
|
||||
@Comment("ybiot设备id")
|
||||
private String ybiotDeviceId;
|
||||
|
||||
|
||||
@Formula("(select time from t_meter_log where meter_id = id order by time asc limit 1)")
|
||||
private LocalDateTime firstLogTime;
|
||||
|
||||
@Formula("(select time from t_meter_log where meter_id = id order by time desc limit 1)")
|
||||
private LocalDateTime lastLogTime;
|
||||
|
||||
@Formula("(select value from t_meter_log where meter_id = id order by time desc limit 1)")
|
||||
private Double lastLogValue;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import jakarta.persistence.Entity;
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Comment;
|
||||
import org.hibernate.annotations.Formula;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@@ -26,6 +29,14 @@ public class MeterEntity extends OrgCommonEntity {
|
||||
@Comment("ybiot设备id")
|
||||
private String ybiotDeviceId;
|
||||
|
||||
@Formula("(select time from t_meter_log l where l.meter_id = id order by l.time asc limit 1)")
|
||||
private LocalDateTime firstLogTime;
|
||||
|
||||
@Formula("(select time from t_meter_log l where l.meter_id = id order by l.time desc limit 1)")
|
||||
private LocalDateTime lastLogTime;
|
||||
|
||||
@Formula("(select value from t_meter_log l where l.meter_id = id order by l.time desc limit 1)")
|
||||
private Double lastLogValue;
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user