This commit is contained in:
“hsc”
2026-08-28 15:20:58 +08:00
16 changed files with 423 additions and 85 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ namespace Model.Dto.Asset
/// <summary>创建时间</summary>
public DateTime? CreateTime { get; set; }
/// <summary>设备Id(关联 EquipmentEntity.Id</summary>
public long EquipmentId { get; set; }
/// <summary>设备Id(关联 EquipmentEntity.Id,雪花 Id 转 string 防精度丢失</summary>
public string EquipmentId { get; set; }
/// <summary>文件名称</summary>
public string? FileName { get; set; }
+2 -2
View File
@@ -14,8 +14,8 @@ namespace Model.Dto.Asset
/// <summary>创建时间</summary>
public DateTime? CreateTime { get; set; }
/// <summary>父级分类Id0表示顶级)</summary>
public long ParentId { get; set; }
/// <summary>父级分类Id0表示顶级,雪花 Id 转 string 防精度丢失</summary>
public string ParentId { get; set; }
/// <summary>分类名称</summary>
public string? Name { get; set; }
+4 -4
View File
@@ -7,8 +7,8 @@ namespace Model.Dto.Asset
/// </summary>
public class EquipmentDto
{
/// <summary>主键 Idlong → string</summary>
public string Id { get; set; }
/// <summary>主键 Idlong → string;入参可空,新增时无需传递</summary>
public string? Id { get; set; }
/// <summary>删除状态(0、未删除;1、已删除)</summary>
public byte IsDel { get; set; }
@@ -22,8 +22,8 @@ namespace Model.Dto.Asset
/// <summary>设备名称</summary>
public string? Name { get; set; }
/// <summary>设备分类Id(关联 EquipmentCategoryEntity.Id</summary>
public long CategoryId { get; set; }
/// <summary>设备分类Id(关联 EquipmentCategoryEntity.Id,雪花 Id 转 string 防精度丢失;可空,未分类时为 "0" 或不传</summary>
public string? CategoryId { get; set; }
/// <summary>设备类型</summary>
public string? Type { get; set; }
@@ -0,0 +1,25 @@
using Model.Entity.Asset;
namespace Model.Dto.Asset
{
/// <summary>
/// 设备状态变更请求 DTOPOST api/asset/equipment/{id}/status 入参)
/// </summary>
public class EquipmentStatusChangeDto
{
/// <summary>
/// 目标状态(必填)
/// </summary>
public EquipmentStatusEnum Status { get; set; }
/// <summary>
/// 操作人
/// </summary>
public string? Operator { get; set; }
/// <summary>
/// 变更原因/备注
/// </summary>
public string? Remark { get; set; }
}
}
+2 -2
View File
@@ -16,8 +16,8 @@ namespace Model.Dto.Asset
/// <summary>创建时间</summary>
public DateTime? CreateTime { get; set; }
/// <summary>设备Id(关联 EquipmentEntity.Id</summary>
public long EquipmentId { get; set; }
/// <summary>设备Id(关联 EquipmentEntity.Id,雪花 Id 转 string 防精度丢失</summary>
public string EquipmentId { get; set; }
/// <summary>变更前状态</summary>
public EquipmentStatusEnum FromStatus { get; set; }
@@ -15,7 +15,7 @@ namespace Model.Entity.Asset
/// <summary>
/// 文件名称
/// </summary>
[SugarColumn(Length = 200)]
[SugarColumn(Length = 200, IsNullable = true)]
public string? FileName { get; set; }
/// <summary>
@@ -26,13 +26,13 @@ namespace Model.Entity.Asset
/// <summary>
/// 文件扩展名(如 .pdf、.jpg
/// </summary>
[SugarColumn(Length = 20)]
[SugarColumn(Length = 20, IsNullable = true)]
public string? FileExt { get; set; }
/// <summary>
/// 文件存储地址(上传后存储的相对路径)
/// </summary>
[SugarColumn(Length = 200)]
[SugarColumn(Length = 200, IsNullable = true)]
public string? FileUrl { get; set; }
/// <summary>
@@ -43,13 +43,13 @@ namespace Model.Entity.Asset
/// <summary>
/// 上传人
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? Uploader { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(Length = 500)]
[SugarColumn(Length = 500, IsNullable = true)]
public string? Remark { get; set; }
}
}
@@ -15,13 +15,13 @@ namespace Model.Entity.Asset
/// <summary>
/// 分类名称
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 分类编码
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? Code { get; set; }
/// <summary>
@@ -37,7 +37,7 @@ namespace Model.Entity.Asset
/// <summary>
/// 备注
/// </summary>
[SugarColumn(Length = 500)]
[SugarColumn(Length = 500, IsNullable = true)]
public string? Remark { get; set; }
}
}
+33 -20
View File
@@ -11,13 +11,13 @@ namespace Model.Entity.Asset
/// <summary>
/// 设备编号(唯一)
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? Code { get; set; }
/// <summary>
/// 设备名称
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
@@ -28,55 +28,55 @@ namespace Model.Entity.Asset
/// <summary>
/// 设备类型(实验室/楼层/部门/位置/产品/自定义等分类维度下的类型名称,冗余便于展示)
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Type { get; set; }
/// <summary>
/// 设备品牌
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Brand { get; set; }
/// <summary>
/// 设备型号
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Model { get; set; }
/// <summary>
/// 规格参数
/// </summary>
[SugarColumn(Length = 200)]
[SugarColumn(Length = 200, IsNullable = true)]
public string? Specifications { get; set; }
/// <summary>
/// 制造商(设备制造商)
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Manufacturer { get; set; }
/// <summary>
/// 供应商(资产供应商)
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Supplier { get; set; }
/// <summary>
/// 设备图片地址(图片上传后存储的相对路径)
/// </summary>
[SugarColumn(Length = 200)]
[SugarColumn(Length = 200, IsNullable = true)]
public string? ImageUrl { get; set; }
/// <summary>
/// 二维码编号(一物一码)
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? QrCode { get; set; }
/// <summary>
/// 设备描述
/// </summary>
[SugarColumn(ColumnDataType = "text")]
[SugarColumn(ColumnDataType = "text", IsNullable = true)]
public string? Description { get; set; }
#endregion
@@ -84,31 +84,31 @@ namespace Model.Entity.Asset
/// <summary>
/// 使用部门名称(资产使用部门)
/// </summary>
[SugarColumn(Length = 100)]
[SugarColumn(Length = 100, IsNullable = true)]
public string? Department { get; set; }
/// <summary>
/// 存放位置(实验室/楼层/房间等位置信息)
/// </summary>
[SugarColumn(Length = 200)]
[SugarColumn(Length = 200, IsNullable = true)]
public string? Location { get; set; }
/// <summary>
/// 责任人(资产责任人)
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? ResponsiblePerson { get; set; }
/// <summary>
/// 责任人联系电话(资产责任人电话)
/// </summary>
[SugarColumn(Length = 30)]
[SugarColumn(Length = 30, IsNullable = true)]
public string? ContactPhone { get; set; }
/// <summary>
/// 保管人
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? Custodian { get; set; }
#endregion
@@ -116,17 +116,19 @@ namespace Model.Entity.Asset
/// <summary>
/// 购置日期
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? PurchaseDate { get; set; }
/// <summary>
/// 购置价格(资产购置价格)
/// </summary>
[SugarColumn(DecimalDigits = 2, Length = 18)]
[SugarColumn(DecimalDigits = 2, Length = 18, IsNullable = true)]
public decimal? PurchasePrice { get; set; }
/// <summary>
/// 保修到期日期(资产保修到期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? WarrantyExpireDate { get; set; }
#endregion
@@ -134,21 +136,25 @@ namespace Model.Entity.Asset
/// <summary>
/// 验收日期(资产验收日期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? AcceptanceDate { get; set; }
/// <summary>
/// 启用日期(资产启用日期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? EnableDate { get; set; }
/// <summary>
/// 使用年限(资产使用年限,单位:年)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? ServiceLifeYears { get; set; }
/// <summary>
/// 报废日期(资产报废日期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? ScrapDate { get; set; }
#endregion
@@ -168,21 +174,25 @@ namespace Model.Entity.Asset
/// <summary>
/// 上次校准日期(校准日期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? LastCalibrationDate { get; set; }
/// <summary>
/// 下次校准到期日期(用于判断是否超期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? NextCalibrationDate { get; set; }
/// <summary>
/// 检定日期
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? InspectionDate { get; set; }
/// <summary>
/// 下次检定到期日期(用于判断是否超期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? NextInspectionDate { get; set; }
/// <summary>
@@ -193,11 +203,13 @@ namespace Model.Entity.Asset
/// <summary>
/// 上次保养日期(保养日期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? LastMaintenanceDate { get; set; }
/// <summary>
/// 下次保养到期日期(保养周期到期,用于判断是否超期)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? NextMaintenanceDate { get; set; }
#endregion
@@ -205,24 +217,25 @@ namespace Model.Entity.Asset
/// <summary>
/// 备注
/// </summary>
[SugarColumn(Length = 500)]
[SugarColumn(Length = 500, IsNullable = true)]
public string? Remark { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? CreateBy { get; set; }
/// <summary>
/// 更新人(修改人)
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? UpdateBy { get; set; }
/// <summary>
/// 更新时间(修改时间)
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? UpdateTime { get; set; }
#endregion
}
@@ -30,13 +30,13 @@ namespace Model.Entity.Asset
/// <summary>
/// 操作人
/// </summary>
[SugarColumn(Length = 50)]
[SugarColumn(Length = 50, IsNullable = true)]
public string? Operator { get; set; }
/// <summary>
/// 变更原因/备注
/// </summary>
[SugarColumn(Length = 500)]
[SugarColumn(Length = 500, IsNullable = true)]
public string? Remark { get; set; }
}
}
+52 -4
View File
@@ -26,7 +26,7 @@ namespace Model.Mapper
CreateTime = entity.CreateTime,
Code = entity.Code,
Name = entity.Name,
CategoryId = entity.CategoryId,
CategoryId = entity.CategoryId.ToString(),
Type = entity.Type,
Brand = entity.Brand,
Model = entity.Model,
@@ -71,6 +71,54 @@ namespace Model.Mapper
{
return entities?.Select(e => e.ToDto()).ToList() ?? new List<EquipmentDto>();
}
/// <summary>
/// EquipmentDto → EquipmentEntity(入参映射,用于新增/修改)
/// 安全约定:IsDel/CreateTime/UpdateTime 等服务端管控字段刻意不映射,防止过度绑定(over-binding);
/// Id 解析失败时为 0(新增时由雪花算法自动生成)
/// </summary>
public static EquipmentEntity ToEntity(this EquipmentDto dto)
{
if (dto == null) return null;
return new EquipmentEntity
{
Id = long.TryParse(dto.Id, out var id) ? id : 0,
Code = dto.Code,
Name = dto.Name,
CategoryId = long.TryParse(dto.CategoryId, out var categoryId) ? categoryId : 0,
Type = dto.Type,
Brand = dto.Brand,
Model = dto.Model,
Specifications = dto.Specifications,
Manufacturer = dto.Manufacturer,
Supplier = dto.Supplier,
ImageUrl = dto.ImageUrl,
QrCode = dto.QrCode,
Description = dto.Description,
Department = dto.Department,
Location = dto.Location,
ResponsiblePerson = dto.ResponsiblePerson,
ContactPhone = dto.ContactPhone,
Custodian = dto.Custodian,
PurchaseDate = dto.PurchaseDate,
PurchasePrice = dto.PurchasePrice,
WarrantyExpireDate = dto.WarrantyExpireDate,
AcceptanceDate = dto.AcceptanceDate,
EnableDate = dto.EnableDate,
ServiceLifeYears = dto.ServiceLifeYears,
ScrapDate = dto.ScrapDate,
Status = dto.Status,
CalibrationStatus = dto.CalibrationStatus,
LastCalibrationDate = dto.LastCalibrationDate,
NextCalibrationDate = dto.NextCalibrationDate,
InspectionDate = dto.InspectionDate,
NextInspectionDate = dto.NextInspectionDate,
MaintenanceStatus = dto.MaintenanceStatus,
LastMaintenanceDate = dto.LastMaintenanceDate,
NextMaintenanceDate = dto.NextMaintenanceDate,
Remark = dto.Remark
};
}
#endregion
#region
@@ -85,7 +133,7 @@ namespace Model.Mapper
Id = entity.Id.ToString(),
IsDel = entity.IsDel,
CreateTime = entity.CreateTime,
EquipmentId = entity.EquipmentId,
EquipmentId = entity.EquipmentId.ToString(),
FileName = entity.FileName,
FileType = entity.FileType,
FileExt = entity.FileExt,
@@ -117,7 +165,7 @@ namespace Model.Mapper
Id = entity.Id.ToString(),
IsDel = entity.IsDel,
CreateTime = entity.CreateTime,
ParentId = entity.ParentId,
ParentId = entity.ParentId.ToString(),
Name = entity.Name,
Code = entity.Code,
Level = entity.Level,
@@ -147,7 +195,7 @@ namespace Model.Mapper
Id = entity.Id.ToString(),
IsDel = entity.IsDel,
CreateTime = entity.CreateTime,
EquipmentId = entity.EquipmentId,
EquipmentId = entity.EquipmentId.ToString(),
FromStatus = entity.FromStatus,
ToStatus = entity.ToStatus,
ChangeTime = entity.ChangeTime,