feat: add spare part management entities
This commit is contained in:
parent
a50178a736
commit
457bafee31
|
|
@ -0,0 +1,83 @@
|
||||||
|
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_spare_part")
|
||||||
|
@Data
|
||||||
|
public class SparePart {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.UUID)
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(name = "project_id", nullable = false)
|
||||||
|
private UUID projectId;
|
||||||
|
|
||||||
|
@Column(name = "spare_part_code", nullable = false, unique = true)
|
||||||
|
private String sparePartCode;
|
||||||
|
|
||||||
|
@Column(name = "spare_part_name", nullable = false)
|
||||||
|
private String sparePartName;
|
||||||
|
|
||||||
|
@Column(name = "category_id")
|
||||||
|
private UUID categoryId;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String specification;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@Column(name = "safe_stock")
|
||||||
|
private Integer safeStock;
|
||||||
|
|
||||||
|
@Column(name = "current_stock")
|
||||||
|
private Integer currentStock;
|
||||||
|
|
||||||
|
@Column(name = "unit_price", precision = 10, scale = 2)
|
||||||
|
private BigDecimal unitPrice;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String supplier;
|
||||||
|
|
||||||
|
@Column(name = "supplier_contact")
|
||||||
|
private String supplierContact;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String location;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
@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();
|
||||||
|
if (currentStock == null) currentStock = 0;
|
||||||
|
if (safeStock == null) safeStock = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreUpdate
|
||||||
|
public void preUpdate() {
|
||||||
|
updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.ether.pms.mdm.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "ops_spare_part_category")
|
||||||
|
@Data
|
||||||
|
public class SparePartCategory {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.UUID)
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(name = "parent_id")
|
||||||
|
private UUID parentId;
|
||||||
|
|
||||||
|
@Column(name = "category_code", nullable = false, unique = true)
|
||||||
|
private String categoryCode;
|
||||||
|
|
||||||
|
@Column(name = "category_name", nullable = false)
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Column(name = "sort_order")
|
||||||
|
private Integer sortOrder;
|
||||||
|
|
||||||
|
@Column(name = "created_at")
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
createdAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.ether.pms.mdm.entity;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "ops_spare_part_record")
|
||||||
|
@Data
|
||||||
|
public class SparePartRecord {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.UUID)
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(name = "record_code", nullable = false, unique = true)
|
||||||
|
private String recordCode;
|
||||||
|
|
||||||
|
@Column(name = "record_type", nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private RecordType recordType;
|
||||||
|
|
||||||
|
public enum RecordType {
|
||||||
|
IN("入库"),
|
||||||
|
OUT("出库"),
|
||||||
|
CHECK("盘点"),
|
||||||
|
ADJUST("调整");
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
RecordType(String desc) { this.desc = desc; }
|
||||||
|
public String getDesc() { return desc; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "spare_part_id", nullable = false)
|
||||||
|
private UUID sparePartId;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private Integer balance;
|
||||||
|
|
||||||
|
@Column(name = "related_order_id")
|
||||||
|
private UUID relatedOrderId;
|
||||||
|
|
||||||
|
@Column(name = "recorded_by")
|
||||||
|
private UUID recordedBy;
|
||||||
|
|
||||||
|
@Column(name = "record_date")
|
||||||
|
private LocalDateTime recordDate;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
if (recordDate == null) {
|
||||||
|
recordDate = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue