diff --git a/IOT_API/Controllers/Inspection/DeviceDashboardController.cs b/IOT_API/Controllers/Inspection/DeviceDashboardController.cs index cf30d4f..f9243e7 100644 --- a/IOT_API/Controllers/Inspection/DeviceDashboardController.cs +++ b/IOT_API/Controllers/Inspection/DeviceDashboardController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Service.Interface; +using Model.Entity.Inspection; namespace WebAPI.Controllers { diff --git a/IOT_API/IOT_API.csproj b/IOT_API/IOT_API.csproj index a66eaf6..fe3f0a4 100644 --- a/IOT_API/IOT_API.csproj +++ b/IOT_API/IOT_API.csproj @@ -7,6 +7,7 @@ + diff --git a/IOT_API/Services/TemperatureBoxSimulator.cs b/IOT_API/Services/TemperatureBoxSimulator.cs index 5d48bf5..6cc33a8 100644 --- a/IOT_API/Services/TemperatureBoxSimulator.cs +++ b/IOT_API/Services/TemperatureBoxSimulator.cs @@ -1,4 +1,4 @@ -using Model.Entity; +using Model.Entity.Inspection; using ORM; namespace WebAPI.Services diff --git a/Model/Dto/Asset/EquipmentAttachmentDto.cs b/Model/Dto/Asset/EquipmentAttachmentDto.cs new file mode 100644 index 0000000..3fa65af --- /dev/null +++ b/Model/Dto/Asset/EquipmentAttachmentDto.cs @@ -0,0 +1,43 @@ +using Model.Entity.Asset; + +namespace Model.Dto.Asset +{ + /// + /// 设备附件 DTO(Id 由 long 改为 string,避免前端精度丢失) + /// + public class EquipmentAttachmentDto + { + /// 主键 Id(long → string) + public string Id { get; set; } + + /// 删除状态(0、未删除;1、已删除) + public byte IsDel { get; set; } + + /// 创建时间 + public DateTime? CreateTime { get; set; } + + /// 设备Id(关联 EquipmentEntity.Id) + public long EquipmentId { get; set; } + + /// 文件名称 + public string? FileName { get; set; } + + /// 文件类型(说明书/合格证/校准证书等) + public AttachmentTypeEnum FileType { get; set; } + + /// 文件扩展名(如 .pdf、.jpg) + public string? FileExt { get; set; } + + /// 文件存储地址 + public string? FileUrl { get; set; } + + /// 文件大小(byte) + public long FileSize { get; set; } + + /// 上传人 + public string? Uploader { get; set; } + + /// 备注 + public string? Remark { get; set; } + } +} diff --git a/Model/Dto/Asset/EquipmentCategoryDto.cs b/Model/Dto/Asset/EquipmentCategoryDto.cs new file mode 100644 index 0000000..47aeb69 --- /dev/null +++ b/Model/Dto/Asset/EquipmentCategoryDto.cs @@ -0,0 +1,35 @@ +namespace Model.Dto.Asset +{ + /// + /// 设备分类 DTO(Id 由 long 改为 string,避免前端精度丢失) + /// + public class EquipmentCategoryDto + { + /// 主键 Id(long → string) + public string Id { get; set; } + + /// 删除状态(0、未删除;1、已删除) + public byte IsDel { get; set; } + + /// 创建时间 + public DateTime? CreateTime { get; set; } + + /// 父级分类Id(0表示顶级) + public long ParentId { get; set; } + + /// 分类名称 + public string? Name { get; set; } + + /// 分类编码 + public string? Code { get; set; } + + /// 层级(1级、2级……) + public int Level { get; set; } + + /// 排序号 + public int Sort { get; set; } + + /// 备注 + public string? Remark { get; set; } + } +} diff --git a/Model/Dto/Asset/EquipmentDto.cs b/Model/Dto/Asset/EquipmentDto.cs new file mode 100644 index 0000000..96be2ad --- /dev/null +++ b/Model/Dto/Asset/EquipmentDto.cs @@ -0,0 +1,130 @@ +using Model.Entity.Asset; + +namespace Model.Dto.Asset +{ + /// + /// 设备台账 DTO(Id 由 long 改为 string,避免前端精度丢失) + /// + public class EquipmentDto + { + /// 主键 Id(long → string) + public string Id { get; set; } + + /// 删除状态(0、未删除;1、已删除) + public byte IsDel { get; set; } + + /// 创建时间 + public DateTime? CreateTime { get; set; } + + /// 设备编号(唯一) + public string? Code { get; set; } + + /// 设备名称 + public string? Name { get; set; } + + /// 设备分类Id(关联 EquipmentCategoryEntity.Id) + public long CategoryId { get; set; } + + /// 设备类型 + public string? Type { get; set; } + + /// 设备品牌 + public string? Brand { get; set; } + + /// 设备型号 + public string? Model { get; set; } + + /// 规格参数 + public string? Specifications { get; set; } + + /// 制造商 + public string? Manufacturer { get; set; } + + /// 供应商 + public string? Supplier { get; set; } + + /// 设备图片地址 + public string? ImageUrl { get; set; } + + /// 二维码编号(一物一码) + public string? QrCode { get; set; } + + /// 设备描述 + public string? Description { get; set; } + + /// 使用部门名称 + public string? Department { get; set; } + + /// 存放位置 + public string? Location { get; set; } + + /// 责任人 + public string? ResponsiblePerson { get; set; } + + /// 责任人联系电话 + public string? ContactPhone { get; set; } + + /// 保管人 + public string? Custodian { get; set; } + + /// 购置日期 + public DateTime? PurchaseDate { get; set; } + + /// 购置价格 + public decimal? PurchasePrice { get; set; } + + /// 保修到期日期 + public DateTime? WarrantyExpireDate { get; set; } + + /// 验收日期 + public DateTime? AcceptanceDate { get; set; } + + /// 启用日期 + public DateTime? EnableDate { get; set; } + + /// 使用年限(年) + public int? ServiceLifeYears { get; set; } + + /// 报废日期 + public DateTime? ScrapDate { get; set; } + + /// 设备当前状态 + public EquipmentStatusEnum Status { get; set; } + + /// 校准状态(正常/超期) + public ComplianceStatusEnum CalibrationStatus { get; set; } + + /// 上次校准日期 + public DateTime? LastCalibrationDate { get; set; } + + /// 下次校准到期日期 + public DateTime? NextCalibrationDate { get; set; } + + /// 检定日期 + public DateTime? InspectionDate { get; set; } + + /// 下次检定到期日期 + public DateTime? NextInspectionDate { get; set; } + + /// 保养状态(正常/超期) + public ComplianceStatusEnum MaintenanceStatus { get; set; } + + /// 上次保养日期 + public DateTime? LastMaintenanceDate { get; set; } + + /// 下次保养到期日期 + public DateTime? NextMaintenanceDate { get; set; } + + /// 备注 + public string? Remark { get; set; } + + /// 创建人 + public string? CreateBy { get; set; } + + /// 更新人 + public string? UpdateBy { get; set; } + + /// 更新时间 + public DateTime? UpdateTime { get; set; } + } +} diff --git a/Model/Dto/Asset/EquipmentStatusRecordDto.cs b/Model/Dto/Asset/EquipmentStatusRecordDto.cs new file mode 100644 index 0000000..35da927 --- /dev/null +++ b/Model/Dto/Asset/EquipmentStatusRecordDto.cs @@ -0,0 +1,37 @@ +using Model.Entity.Asset; + +namespace Model.Dto.Asset +{ + /// + /// 设备状态记录 DTO(Id 由 long 改为 string,避免前端精度丢失) + /// + public class EquipmentStatusRecordDto + { + /// 主键 Id(long → string) + public string Id { get; set; } + + /// 删除状态(0、未删除;1、已删除) + public byte IsDel { get; set; } + + /// 创建时间 + public DateTime? CreateTime { get; set; } + + /// 设备Id(关联 EquipmentEntity.Id) + public long EquipmentId { get; set; } + + /// 变更前状态 + public EquipmentStatusEnum FromStatus { get; set; } + + /// 变更后状态 + public EquipmentStatusEnum ToStatus { get; set; } + + /// 状态变更时间 + public DateTime ChangeTime { get; set; } + + /// 操作人 + public string? Operator { get; set; } + + /// 变更原因/备注 + public string? Remark { get; set; } + } +} diff --git a/Model/Dto/Inspection/TemperatureBoxDataDto.cs b/Model/Dto/Inspection/TemperatureBoxDataDto.cs new file mode 100644 index 0000000..1c1b8f7 --- /dev/null +++ b/Model/Dto/Inspection/TemperatureBoxDataDto.cs @@ -0,0 +1,35 @@ +namespace Model.Dto.Inspection +{ + /// + /// 温度箱看板数据 DTO(Id 由 long 改为 string,避免前端精度丢失) + /// + public class TemperatureBoxDataDto + { + /// 主键 Id(long → string) + public string Id { get; set; } + + /// 删除状态(0、未删除;1、已删除) + public byte IsDel { get; set; } + + /// 采集时间 + public DateTime? CreateTime { get; set; } + + /// 设备标识 + public string DeviceCode { get; set; } + + /// 设备类型 + public string DeviceType { get; set; } + + /// 设备温度(℃) + public double? DeviceTemperature { get; set; } + + /// 设备湿度(%) + public double? DeviceHumidity { get; set; } + + /// 设备状态 + public string Status { get; set; } + + /// 设备告警信息 + public string AlarmInfo { get; set; } + } +} diff --git a/Model/Entity/TemperatureBoxDataEntity.cs b/Model/Entity/Inspection/TemperatureBoxDataEntity.cs similarity index 98% rename from Model/Entity/TemperatureBoxDataEntity.cs rename to Model/Entity/Inspection/TemperatureBoxDataEntity.cs index 17b5a49..1a9a247 100644 --- a/Model/Entity/TemperatureBoxDataEntity.cs +++ b/Model/Entity/Inspection/TemperatureBoxDataEntity.cs @@ -1,7 +1,7 @@ using SqlSugar; using System; -namespace Model.Entity +namespace Model.Entity.Inspection { /// /// 温度箱看板数据实体 diff --git a/Model/Mapper/EntityMapper.cs b/Model/Mapper/EntityMapper.cs new file mode 100644 index 0000000..ea077dc --- /dev/null +++ b/Model/Mapper/EntityMapper.cs @@ -0,0 +1,198 @@ +using Model.Dto.Asset; +using Model.Dto.Inspection; +using Model.Entity.Asset; +using Model.Entity.Inspection; + +namespace Model.Mapper +{ + /// + /// Entity → DTO 映射器(统一在此处做实体到传输对象的转换) + /// 核心转换:雪花 Id 由 long 转 string,避免前端 JavaScript 大数精度丢失 + /// 使用方法 给查询的数据后面加上.ToDtoList()或者.ToDto() + /// + public static class EntityMapper + { + #region 设备台账 + /// + /// EquipmentEntity → EquipmentDto + /// + public static EquipmentDto ToDto(this EquipmentEntity entity) + { + if (entity == null) return null; + return new EquipmentDto + { + Id = entity.Id.ToString(), + IsDel = entity.IsDel, + CreateTime = entity.CreateTime, + Code = entity.Code, + Name = entity.Name, + CategoryId = entity.CategoryId, + Type = entity.Type, + Brand = entity.Brand, + Model = entity.Model, + Specifications = entity.Specifications, + Manufacturer = entity.Manufacturer, + Supplier = entity.Supplier, + ImageUrl = entity.ImageUrl, + QrCode = entity.QrCode, + Description = entity.Description, + Department = entity.Department, + Location = entity.Location, + ResponsiblePerson = entity.ResponsiblePerson, + ContactPhone = entity.ContactPhone, + Custodian = entity.Custodian, + PurchaseDate = entity.PurchaseDate, + PurchasePrice = entity.PurchasePrice, + WarrantyExpireDate = entity.WarrantyExpireDate, + AcceptanceDate = entity.AcceptanceDate, + EnableDate = entity.EnableDate, + ServiceLifeYears = entity.ServiceLifeYears, + ScrapDate = entity.ScrapDate, + Status = entity.Status, + CalibrationStatus = entity.CalibrationStatus, + LastCalibrationDate = entity.LastCalibrationDate, + NextCalibrationDate = entity.NextCalibrationDate, + InspectionDate = entity.InspectionDate, + NextInspectionDate = entity.NextInspectionDate, + MaintenanceStatus = entity.MaintenanceStatus, + LastMaintenanceDate = entity.LastMaintenanceDate, + NextMaintenanceDate = entity.NextMaintenanceDate, + Remark = entity.Remark, + CreateBy = entity.CreateBy, + UpdateBy = entity.UpdateBy, + UpdateTime = entity.UpdateTime + }; + } + + /// + /// List<EquipmentEntity> → List<EquipmentDto> + /// + public static List ToDtoList(this List entities) + { + return entities?.Select(e => e.ToDto()).ToList() ?? new List(); + } + #endregion + + #region 设备附件 + /// + /// EquipmentAttachmentEntity → EquipmentAttachmentDto + /// + public static EquipmentAttachmentDto ToDto(this EquipmentAttachmentEntity entity) + { + if (entity == null) return null; + return new EquipmentAttachmentDto + { + Id = entity.Id.ToString(), + IsDel = entity.IsDel, + CreateTime = entity.CreateTime, + EquipmentId = entity.EquipmentId, + FileName = entity.FileName, + FileType = entity.FileType, + FileExt = entity.FileExt, + FileUrl = entity.FileUrl, + FileSize = entity.FileSize, + Uploader = entity.Uploader, + Remark = entity.Remark + }; + } + + /// + /// List<EquipmentAttachmentEntity> → List<EquipmentAttachmentDto> + /// + public static List ToDtoList(this List entities) + { + return entities?.Select(e => e.ToDto()).ToList() ?? new List(); + } + #endregion + + #region 设备分类 + /// + /// EquipmentCategoryEntity → EquipmentCategoryDto + /// + public static EquipmentCategoryDto ToDto(this EquipmentCategoryEntity entity) + { + if (entity == null) return null; + return new EquipmentCategoryDto + { + Id = entity.Id.ToString(), + IsDel = entity.IsDel, + CreateTime = entity.CreateTime, + ParentId = entity.ParentId, + Name = entity.Name, + Code = entity.Code, + Level = entity.Level, + Sort = entity.Sort, + Remark = entity.Remark + }; + } + + /// + /// List<EquipmentCategoryEntity> → List<EquipmentCategoryDto> + /// + public static List ToDtoList(this List entities) + { + return entities?.Select(e => e.ToDto()).ToList() ?? new List(); + } + #endregion + + #region 设备状态记录 + /// + /// EquipmentStatusRecordEntity → EquipmentStatusRecordDto + /// + public static EquipmentStatusRecordDto ToDto(this EquipmentStatusRecordEntity entity) + { + if (entity == null) return null; + return new EquipmentStatusRecordDto + { + Id = entity.Id.ToString(), + IsDel = entity.IsDel, + CreateTime = entity.CreateTime, + EquipmentId = entity.EquipmentId, + FromStatus = entity.FromStatus, + ToStatus = entity.ToStatus, + ChangeTime = entity.ChangeTime, + Operator = entity.Operator, + Remark = entity.Remark + }; + } + + /// + /// List<EquipmentStatusRecordEntity> → List<EquipmentStatusRecordDto> + /// + public static List ToDtoList(this List entities) + { + return entities?.Select(e => e.ToDto()).ToList() ?? new List(); + } + #endregion + + #region 温度箱看板数据 + /// + /// TemperatureBoxDataEntity → TemperatureBoxDataDto + /// + public static TemperatureBoxDataDto ToDto(this TemperatureBoxDataEntity entity) + { + if (entity == null) return null; + return new TemperatureBoxDataDto + { + Id = entity.Id.ToString(), + IsDel = entity.IsDel, + CreateTime = entity.CreateTime, + DeviceCode = entity.DeviceCode, + DeviceType = entity.DeviceType, + DeviceTemperature = entity.DeviceTemperature, + DeviceHumidity = entity.DeviceHumidity, + Status = entity.Status, + AlarmInfo = entity.AlarmInfo + }; + } + + /// + /// List<TemperatureBoxDataEntity> → List<TemperatureBoxDataDto> + /// + public static List ToDtoList(this List entities) + { + return entities?.Select(e => e.ToDto()).ToList() ?? new List(); + } + #endregion + } +} diff --git a/Model/Model.csproj b/Model/Model.csproj index caf2bb7..c3fac92 100644 --- a/Model/Model.csproj +++ b/Model/Model.csproj @@ -6,14 +6,17 @@ enable - - - - - - + + + + + + + + + diff --git a/Service/Implement/Inspection/DeviceDashboardService.cs b/Service/Implement/Inspection/DeviceDashboardService.cs index 3d85167..5e6cc36 100644 --- a/Service/Implement/Inspection/DeviceDashboardService.cs +++ b/Service/Implement/Inspection/DeviceDashboardService.cs @@ -1,5 +1,5 @@ using Model; -using Model.Entity; +using Model.Entity.Inspection; using ORM; using Service.Interface; using SqlSugar; diff --git a/Service/Interface/Inspection/IDeviceDashboardService.cs b/Service/Interface/Inspection/IDeviceDashboardService.cs index 8952c98..ea071c7 100644 --- a/Service/Interface/Inspection/IDeviceDashboardService.cs +++ b/Service/Interface/Inspection/IDeviceDashboardService.cs @@ -1,5 +1,5 @@ using Model; -using Model.Entity; +using Model.Entity.Inspection; using System.Collections.Generic; using System.Threading.Tasks;