Browse Source

职业病

bjmzak
wxd 1 year ago
parent
commit
ab6ba42dca
  1. 31
      src/Shentun.Peis.Application.Contracts/Poisons/PoisonWithTypeDto.cs
  2. 39
      src/Shentun.Peis.Application/Poisons/PoisonAppService.cs

31
src/Shentun.Peis.Application.Contracts/Poisons/PoisonWithTypeDto.cs

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.Poisons
{
public class PoisonWithTypeDto
{
public string PoisonTypeName { get; set; }
public List<PoisonWithTypeSimpePoison> poisonDtos { get; set; }
}
public class PoisonWithTypeSimpePoison
{
public Guid Id { get; set; }
/// <summary>
/// 毒害因素名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// 自定义简码
/// </summary>
public string SimpleCode { get; set; }
}
}

39
src/Shentun.Peis.Application/Poisons/PoisonAppService.cs

@ -13,7 +13,7 @@ using Volo.Abp.Domain.Repositories;
namespace Shentun.Peis.Poisons
{
/// <summary>
/// 毒害因素
@ -23,17 +23,20 @@ namespace Shentun.Peis.Poisons
public class PoisonAppService : ApplicationService
{
private readonly IRepository<Poison, Guid> _poisonRepository;
private readonly IRepository<PoisonType, Guid> _poisonTypeRepository;
private readonly PoisonManager _poisonManager;
private readonly CacheService _cacheService;
public PoisonAppService(
IRepository<Poison, Guid> poisonRepository,
PoisonManager poisonManager,
CacheService cacheService)
CacheService cacheService,
IRepository<PoisonType, Guid> poisonTypeRepository)
{
_poisonRepository = poisonRepository;
_poisonManager = poisonManager;
_cacheService = cacheService;
_poisonTypeRepository = poisonTypeRepository;
}
/// <summary>
@ -80,6 +83,38 @@ namespace Shentun.Peis.Poisons
}
/// <summary>
/// 获取毒害因素,附加毒害类别
/// </summary>
/// <returns></returns>
[HttpPost("api/app/Poison/GetPoisonWithTypeList")]
public async Task<List<PoisonWithTypeDto>> GetPoisonWithTypeListAsync()
{
var poisonList = (from poison in await _poisonRepository.GetQueryableAsync()
join poisonType in await _poisonTypeRepository.GetQueryableAsync() on poison.PoisonTypeId equals poisonType.Id into poisonTypeTemp
from poisonTypeHaveEmpty in poisonTypeTemp.DefaultIfEmpty()
select new
{
PoisonTypeName = poisonTypeHaveEmpty != null ? poisonTypeHaveEmpty.DisplayName : "",
poison
}).ToList();
var entDto = poisonList.GroupBy(g => g.poison.PoisonTypeId).Select(s => new PoisonWithTypeDto
{
PoisonTypeName = s.FirstOrDefault().PoisonTypeName,
poisonDtos = s.Select(ss => new PoisonWithTypeSimpePoison
{
DisplayName = ss.poison.DisplayName,
Id = ss.poison.Id,
SimpleCode = ss.poison.SimpleCode
}).ToList()
}).ToList();
return entDto;
}
/// <summary>
/// 创建
/// </summary>

Loading…
Cancel
Save