feat: add energy monitoring entities (EnergyMeter, EnergyConsumption)
This commit is contained in:
parent
8b5a002f3f
commit
1f4aa569e3
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.ether.pms.mdm.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "ops_energy_consumption")
|
||||||
|
@Data
|
||||||
|
public class EnergyConsumption {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.UUID)
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(name = "project_id", nullable = false)
|
||||||
|
private UUID projectId;
|
||||||
|
|
||||||
|
@Column(name = "meter_id", nullable = false)
|
||||||
|
private UUID meterId;
|
||||||
|
|
||||||
|
@Column(name = "consumption_date", nullable = false)
|
||||||
|
private LocalDate consumptionDate;
|
||||||
|
|
||||||
|
@Column(name = "previous_reading", precision = 12, scale = 2)
|
||||||
|
private BigDecimal previousReading;
|
||||||
|
|
||||||
|
@Column(name = "current_reading", precision = 12, scale = 2)
|
||||||
|
private BigDecimal currentReading;
|
||||||
|
|
||||||
|
@Column(nullable = false, precision = 12, scale = 2)
|
||||||
|
private BigDecimal consumption;
|
||||||
|
|
||||||
|
@Column(precision = 10, scale = 2)
|
||||||
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
@Column(name = "recorded_by")
|
||||||
|
private UUID recordedBy;
|
||||||
|
|
||||||
|
@Column(name = "record_method")
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private RecordMethod recordMethod = RecordMethod.MANUAL;
|
||||||
|
|
||||||
|
public enum RecordMethod {
|
||||||
|
MANUAL, // 手动录入
|
||||||
|
IOT // IoT自动采集
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
@Column(name = "created_at")
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
createdAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.ether.pms.mdm.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "ops_energy_meter")
|
||||||
|
@Data
|
||||||
|
public class EnergyMeter {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.UUID)
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(name = "project_id", nullable = false)
|
||||||
|
private UUID projectId;
|
||||||
|
|
||||||
|
@Column(name = "meter_code", nullable = false, unique = true)
|
||||||
|
private String meterCode;
|
||||||
|
|
||||||
|
@Column(name = "meter_name", nullable = false)
|
||||||
|
private String meterName;
|
||||||
|
|
||||||
|
@Column(name = "energy_type", nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private EnergyType energyType;
|
||||||
|
|
||||||
|
public enum EnergyType {
|
||||||
|
LIGHTING("照明插座用电"),
|
||||||
|
HVAC("空调用电"),
|
||||||
|
POWER("动力用电"),
|
||||||
|
SPECIAL("特殊用电"),
|
||||||
|
WATER("给排水"),
|
||||||
|
GAS("燃气");
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
EnergyType(String desc) { this.desc = desc; }
|
||||||
|
public String getDesc() { return desc; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "space_node_id")
|
||||||
|
private UUID spaceNodeId;
|
||||||
|
|
||||||
|
@Column(name = "installation_location")
|
||||||
|
private String installationLocation;
|
||||||
|
|
||||||
|
@Column(name = "rated_capacity", precision = 10, scale = 2)
|
||||||
|
private BigDecimal ratedCapacity;
|
||||||
|
|
||||||
|
@Column(name = "unit_price", precision = 10, scale = 4)
|
||||||
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Status status = Status.ACTIVE;
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
ACTIVE, INACTIVE
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "created_at")
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@Column(name = "updated_at")
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
createdAt = LocalDateTime.now();
|
||||||
|
updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreUpdate
|
||||||
|
public void preUpdate() {
|
||||||
|
updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue