feat: add MaintenanceTask entity
This commit is contained in:
parent
efdc4b71f6
commit
305e09101a
|
|
@ -0,0 +1,95 @@
|
|||
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_maintenance_task")
|
||||
@Data
|
||||
public class MaintenanceTask {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.UUID)
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "project_id", nullable = false)
|
||||
private UUID projectId;
|
||||
|
||||
@Column(name = "task_code", nullable = false, unique = true)
|
||||
private String taskCode;
|
||||
|
||||
@Column(name = "plan_id")
|
||||
private UUID planId;
|
||||
|
||||
@Column(name = "equipment_id")
|
||||
private UUID equipmentId;
|
||||
|
||||
@Column(name = "task_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private TaskType taskType = TaskType.PREVENTIVE;
|
||||
|
||||
public enum TaskType {
|
||||
PREVENTIVE, // 预防性维护
|
||||
CORRECTIVE // 纠正性维护
|
||||
}
|
||||
|
||||
@Column(name = "trigger_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private MaintenancePlan.TriggerType triggerType;
|
||||
|
||||
@Column(name = "maintenance_items", columnDefinition = "TEXT")
|
||||
private String maintenanceItems;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status status = Status.PENDING;
|
||||
|
||||
public enum Status {
|
||||
PENDING, // 待接受
|
||||
ACCEPTED, // 已接受
|
||||
IN_PROGRESS, // 执行中
|
||||
COMPLETED, // 已完成
|
||||
CANCELLED // 已取消
|
||||
}
|
||||
|
||||
@Column(name = "assigned_to")
|
||||
private UUID assignedTo;
|
||||
|
||||
@Column(name = "scheduled_date")
|
||||
private LocalDateTime scheduledDate;
|
||||
|
||||
@Column(name = "actual_start_date")
|
||||
private LocalDateTime actualStartDate;
|
||||
|
||||
@Column(name = "actual_end_date")
|
||||
private LocalDateTime actualEndDate;
|
||||
|
||||
@Column(name = "labor_hours", precision = 10, scale = 2)
|
||||
private BigDecimal laborHours;
|
||||
|
||||
@Column(name = "materials_cost", precision = 12, scale = 2)
|
||||
private BigDecimal materialsCost;
|
||||
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String remarks;
|
||||
|
||||
@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