Browse Source

仪器设备

master
wxd 12 months ago
parent
commit
ac5f7ab685
  1. 12
      src/Shentun.Peis.Application.Contracts/Devices/CreateDeviceDto.cs
  2. 11
      src/Shentun.Peis.Application.Contracts/Devices/DeviceCodeInputDto.cs
  3. 11
      src/Shentun.Peis.Application.Contracts/Devices/DeviceDto.cs
  4. 14
      src/Shentun.Peis.Application.Contracts/Devices/GetDeviceImageTypeByDeviceCodeDto.cs
  5. 10
      src/Shentun.Peis.Application.Contracts/Devices/UpdateDeviceDto.cs
  6. 31
      src/Shentun.Peis.Application/Devices/DeviceAppService.cs
  7. 16
      src/Shentun.Peis.Domain/Devices/Device.cs
  8. 20
      src/Shentun.Peis.Domain/Devices/DeviceManager.cs
  9. 4
      src/Shentun.Peis.EntityFrameworkCore/DbMapping/Devices/DeviceDbMapping.cs
  10. 16157
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20241121123435_update_device_code.Designer.cs
  11. 66
      src/Shentun.Peis.EntityFrameworkCore/Migrations/20241121123435_update_device_code.cs
  12. 16
      src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

12
src/Shentun.Peis.Application.Contracts/Devices/CreateDeviceDto.cs

@ -26,6 +26,16 @@ namespace Shentun.Peis.Devices
/// </summary> /// </summary>
public string AeTitle { get; set; } public string AeTitle { get; set; }
/// <summary>
/// 编码
/// </summary>
public string DeviceCode { get; set; }
/// <summary>
/// 仪器图片类型 (0-仪器图片 1-报告图片)
/// </summary>
public char DeviceImageType { get; set; }
} }
} }

11
src/Shentun.Peis.Application.Contracts/Devices/DeviceCodeInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.Devices
{
public class DeviceCodeInputDto
{
public string DeviceCode { get; set; }
}
}

11
src/Shentun.Peis.Application.Contracts/Devices/DeviceDto.cs

@ -38,5 +38,16 @@ namespace Shentun.Peis.Devices
/// 排序 /// 排序
/// </summary> /// </summary>
public int DisplayOrder { get; set; } public int DisplayOrder { get; set; }
/// <summary>
/// 编码
/// </summary>
public string DeviceCode { get; set; }
/// <summary>
/// 仪器图片类型 (0-仪器图片 1-报告图片)
/// </summary>
public char DeviceImageType { get; set; }
} }
} }

14
src/Shentun.Peis.Application.Contracts/Devices/GetDeviceImageTypeByDeviceCodeDto.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.Devices
{
public class GetDeviceImageTypeByDeviceCodeDto
{
/// <summary>
/// 仪器图片类型
/// </summary>
public char DeviceImageType { get; set; }
}
}

10
src/Shentun.Peis.Application.Contracts/Devices/UpdateDeviceDto.cs

@ -30,5 +30,15 @@ namespace Shentun.Peis.Devices
/// DICOM设备AETitle 该一般字段存储英文字符,仅DICOM设备需要设置 /// DICOM设备AETitle 该一般字段存储英文字符,仅DICOM设备需要设置
/// </summary> /// </summary>
public string AeTitle { get; set; } public string AeTitle { get; set; }
/// <summary>
/// 编码
/// </summary>
public string DeviceCode { get; set; }
/// <summary>
/// 仪器图片类型 (0-仪器图片 1-报告图片)
/// </summary>
public char DeviceImageType { get; set; }
} }
} }

31
src/Shentun.Peis.Application/Devices/DeviceAppService.cs

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
@ -83,7 +84,9 @@ namespace Shentun.Peis.Devices
LastModificationTime = s.LastModificationTime, LastModificationTime = s.LastModificationTime,
LastModifierId = s.LastModifierId, LastModifierId = s.LastModifierId,
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result,
DeviceCode = s.DeviceCode,
DeviceImageType = s.DeviceImageType
}).OrderBy(o => o.DisplayOrder).ToList(); }).OrderBy(o => o.DisplayOrder).ToList();
return entdto; return entdto;
@ -91,6 +94,32 @@ namespace Shentun.Peis.Devices
} }
/// <summary>
/// 获取仪器图片类型 根据仪器编码
/// </summary>
/// <returns></returns>
[HttpPost("api/app/Device/GetDeviceImageTypeByDeviceCode")]
public async Task<GetDeviceImageTypeByDeviceCodeDto> GetDeviceImageTypeByDeviceCodeAsync(DeviceCodeInputDto input)
{
if (string.IsNullOrWhiteSpace(input.DeviceCode))
{
throw new UserFriendlyException("设备编码不能为空");
}
var deviceEnt = await _deviceRepository.FirstOrDefaultAsync(f => f.DeviceCode == input.DeviceCode);
if (deviceEnt == null)
{
throw new UserFriendlyException("设备编码不正确");
}
return new GetDeviceImageTypeByDeviceCodeDto
{
DeviceImageType = deviceEnt.DeviceImageType
};
}
/// <summary> /// <summary>
/// 创建 /// 创建
/// </summary> /// </summary>

16
src/Shentun.Peis.Domain/Devices/Device.cs

@ -13,6 +13,7 @@ namespace Shentun.Peis.Models
/// <summary> /// <summary>
/// 仪器表 /// 仪器表
/// </summary> /// </summary>
[Table("device")]
public class Device : AuditedEntity<Guid>, IHasConcurrencyStamp, IDisplayName, IDisplayOrder public class Device : AuditedEntity<Guid>, IHasConcurrencyStamp, IDisplayName, IDisplayOrder
{ {
public Device(Guid id) : base(id) public Device(Guid id) : base(id)
@ -64,6 +65,21 @@ namespace Shentun.Peis.Models
[Column("display_order")] [Column("display_order")]
public int DisplayOrder { get; set; } public int DisplayOrder { get; set; }
/// <summary>
/// 编码
/// </summary>
[Column("device_code")]
[StringLength(3)]
public string DeviceCode { get; set; }
/// <summary>
/// 仪器图片类型 (0-仪器图片 1-报告图片)
/// </summary>
[Column("device_image_type")]
[MaxLength(1)]
public char DeviceImageType { get; set; }
[Column("concurrency_stamp")] [Column("concurrency_stamp")]
public string ConcurrencyStamp { get; set; } public string ConcurrencyStamp { get; set; }

20
src/Shentun.Peis.Domain/Devices/DeviceManager.cs

@ -40,6 +40,13 @@ namespace Shentun.Peis.Devices
) )
{ {
Verify(entity); Verify(entity);
var existEntity = await _deviceRepository.FirstOrDefaultAsync(o => o.DeviceCode == entity.DeviceCode);
if (existEntity != null)
{
throw new UserFriendlyException("编码已存在");
}
await EntityHelper.CheckSameName(_deviceRepository, entity.DisplayName); await EntityHelper.CheckSameName(_deviceRepository, entity.DisplayName);
return new Device(GuidGenerator.Create()) return new Device(GuidGenerator.Create())
{ {
@ -48,7 +55,9 @@ namespace Shentun.Peis.Devices
SimpleCode = LanguageConverter.GetPYSimpleCode(entity.DisplayName), SimpleCode = LanguageConverter.GetPYSimpleCode(entity.DisplayName),
AeTitle = entity.AeTitle, AeTitle = entity.AeTitle,
DeviceTypeId = entity.DeviceTypeId, DeviceTypeId = entity.DeviceTypeId,
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder(_deviceRepository)
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder(_deviceRepository),
DeviceImageType = entity.DeviceImageType,
DeviceCode = entity.DeviceCode
}; };
} }
@ -65,6 +74,13 @@ namespace Shentun.Peis.Devices
{ {
DataHelper.CheckEntityIsNull(sourceEntity); DataHelper.CheckEntityIsNull(sourceEntity);
Verify(targetEntity); Verify(targetEntity);
var existEntity = await _deviceRepository.FirstOrDefaultAsync(o => o.DeviceCode == sourceEntity.DeviceCode && o.Id != sourceEntity.Id);
if (existEntity != null)
{
throw new UserFriendlyException("编码已存在");
}
if (sourceEntity.DisplayName != targetEntity.DisplayName) if (sourceEntity.DisplayName != targetEntity.DisplayName)
{ {
@ -76,6 +92,8 @@ namespace Shentun.Peis.Devices
targetEntity.DeviceTypeId = sourceEntity.DeviceTypeId; targetEntity.DeviceTypeId = sourceEntity.DeviceTypeId;
targetEntity.DeviceProtocolFlag = sourceEntity.DeviceProtocolFlag; targetEntity.DeviceProtocolFlag = sourceEntity.DeviceProtocolFlag;
targetEntity.AeTitle = sourceEntity.AeTitle; targetEntity.AeTitle = sourceEntity.AeTitle;
targetEntity.DeviceImageType = sourceEntity.DeviceImageType;
targetEntity.DeviceCode = sourceEntity.DeviceCode;
} }

4
src/Shentun.Peis.EntityFrameworkCore/DbMapping/Devices/DeviceDbMapping.cs

@ -16,11 +16,13 @@ namespace Shentun.Peis.DbMapping
public void Configure(EntityTypeBuilder<Device> entity) public void Configure(EntityTypeBuilder<Device> entity)
{ {
entity.HasComment("设备表"); entity.HasComment("设备表");
entity.Property(t => t.DisplayName).HasComment("设备名称"); entity.Property(t => t.DisplayName).HasComment("设备名称");
entity.Property(t => t.DeviceTypeId).HasComment("仪器类别ID"); entity.Property(t => t.DeviceTypeId).HasComment("仪器类别ID");
entity.Property(t => t.DeviceProtocolFlag).HasComment("设备协议"); entity.Property(t => t.DeviceProtocolFlag).HasComment("设备协议");
entity.Property(t => t.AeTitle).HasComment("DICOM设备AETitle"); entity.Property(t => t.AeTitle).HasComment("DICOM设备AETitle");
entity.Property(t => t.DeviceCode).HasComment("设备编码");
entity.Property(t => t.DeviceImageType).HasComment("仪器图片类型").HasDefaultValueSql("'0'"); ;
entity.ConfigureByConvention(); entity.ConfigureByConvention();
} }

16157
src/Shentun.Peis.EntityFrameworkCore/Migrations/20241121123435_update_device_code.Designer.cs
File diff suppressed because it is too large
View File

66
src/Shentun.Peis.EntityFrameworkCore/Migrations/20241121123435_update_device_code.cs

@ -0,0 +1,66 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.Peis.Migrations
{
public partial class update_device_code : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Devices",
table: "Devices");
migrationBuilder.RenameTable(
name: "Devices",
newName: "device");
migrationBuilder.AddColumn<string>(
name: "device_code",
table: "device",
type: "character varying(3)",
maxLength: 3,
nullable: true,
comment: "设备编码");
migrationBuilder.AddColumn<char>(
name: "device_image_type",
table: "device",
type: "character(1)",
maxLength: 1,
nullable: false,
defaultValueSql: "'0'",
comment: "仪器图片类型");
migrationBuilder.AddPrimaryKey(
name: "PK_device",
table: "device",
column: "id");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_device",
table: "device");
migrationBuilder.DropColumn(
name: "device_code",
table: "device");
migrationBuilder.DropColumn(
name: "device_image_type",
table: "device");
migrationBuilder.RenameTable(
name: "device",
newName: "Devices");
migrationBuilder.AddPrimaryKey(
name: "PK_Devices",
table: "Devices",
column: "id");
}
}
}

16
src/Shentun.Peis.EntityFrameworkCore/Migrations/PeisDbContextModelSnapshot.cs

@ -3532,6 +3532,20 @@ namespace Shentun.Peis.Migrations
.HasColumnType("uuid") .HasColumnType("uuid")
.HasColumnName("creator_id"); .HasColumnName("creator_id");
b.Property<string>("DeviceCode")
.HasMaxLength(3)
.HasColumnType("character varying(3)")
.HasColumnName("device_code")
.HasComment("设备编码");
b.Property<char>("DeviceImageType")
.ValueGeneratedOnAdd()
.HasMaxLength(1)
.HasColumnType("character(1)")
.HasColumnName("device_image_type")
.HasDefaultValueSql("'0'")
.HasComment("仪器图片类型");
b.Property<char>("DeviceProtocolFlag") b.Property<char>("DeviceProtocolFlag")
.HasColumnType("character(1)") .HasColumnType("character(1)")
.HasColumnName("device_protocol_flag") .HasColumnName("device_protocol_flag")
@ -3569,7 +3583,7 @@ namespace Shentun.Peis.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Devices");
b.ToTable("device");
b.HasComment("设备表"); b.HasComment("设备表");
}); });

Loading…
Cancel
Save