Browse Source

汇总项目类别

bjmzak
wxd 2 years ago
parent
commit
f94cc53a15
  1. 8
      src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs
  2. 4
      src/Shentun.Peis.Application.Contracts/Asbitems/CreateAsbitemDto.cs
  3. 4
      src/Shentun.Peis.Application.Contracts/Asbitems/UpdateAsbitemDto.cs
  4. 27
      src/Shentun.Peis.Application.Contracts/CollectItemTypes/CollectItemTypeDto.cs
  5. 22
      src/Shentun.Peis.Application.Contracts/CollectItemTypes/CreateCollectItemTypeDto.cs
  6. 23
      src/Shentun.Peis.Application.Contracts/CollectItemTypes/UpdateCollectItemTypeDto.cs
  7. 1
      src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs
  8. 164
      src/Shentun.Peis.Application/CollectItemTypes/CollectItemTypeAppService.cs
  9. 7
      src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
  10. 107
      src/Shentun.Peis.Domain/CollectItemTypes/CollectItemTypeManager.cs

8
src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs

@ -42,10 +42,10 @@ namespace Shentun.Peis.Asbitems
public Guid? DeviceTypeId { get; set; } public Guid? DeviceTypeId { get; set; }
///// <summary>
///// 发票类别
///// </summary>
//public Guid InvoiceItemTypeId { get; set; }
/// <summary>
/// 汇总项目类别ID
/// </summary>
public Guid CollectItemTypeId { get; set; }
/// <summary> /// <summary>

4
src/Shentun.Peis.Application.Contracts/Asbitems/CreateAsbitemDto.cs

@ -40,9 +40,9 @@ namespace Shentun.Peis.Asbitems
/// <summary> /// <summary>
/// 发票类别
/// 汇总项目类别ID
/// </summary> /// </summary>
public Guid InvoiceItemTypeId { get; set; }
public Guid CollectItemType { get; set; }
/// <summary> /// <summary>

4
src/Shentun.Peis.Application.Contracts/Asbitems/UpdateAsbitemDto.cs

@ -40,9 +40,9 @@ namespace Shentun.Peis.Asbitems
/// <summary> /// <summary>
/// 发票类别
/// 汇总项目类别ID
/// </summary> /// </summary>
public Guid InvoiceItemTypeId { get; set; }
public Guid CollectItemTypeId { get; set; }
/// <summary> /// <summary>

27
src/Shentun.Peis.Application.Contracts/CollectItemTypes/CollectItemTypeDto.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Shentun.Peis.CollectItemTypes
{
public class CollectItemTypeDto : AuditedEntityDtoName
{
/// <summary>
/// 名称
/// </summary>
public string DisplayName { get; set; }
public string SimpleCode { get; set; }
/// <summary>
/// 发票项目类别ID
/// </summary>
public Guid InvoiceItemTypeId { get; set; }
public int DisplayOrder { get; set; }
}
}

22
src/Shentun.Peis.Application.Contracts/CollectItemTypes/CreateCollectItemTypeDto.cs

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Shentun.Peis.CollectItemTypes
{
public class CreateCollectItemTypeDto
{
/// <summary>
/// 名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// 发票项目类别ID
/// </summary>
public Guid InvoiceItemTypeId { get; set; }
}
}

23
src/Shentun.Peis.Application.Contracts/CollectItemTypes/UpdateCollectItemTypeDto.cs

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.CollectItemTypes
{
public class UpdateCollectItemTypeDto
{
public Guid Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// 发票项目类别ID
/// </summary>
public Guid InvoiceItemTypeId { get; set; }
}
}

1
src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs

@ -122,6 +122,7 @@ namespace Shentun.Peis.Asbitems
DisplayOrder = s.a.DisplayOrder, DisplayOrder = s.a.DisplayOrder,
ForSexId = s.a.ForSexId, ForSexId = s.a.ForSexId,
Id = s.a.Id, Id = s.a.Id,
CollectItemTypeId = s.a.CollectItemTypeId,
//InvoiceItemTypeId = s.a.InvoiceItemTypeId, //InvoiceItemTypeId = s.a.InvoiceItemTypeId,
IsActive = s.a.IsActive, IsActive = s.a.IsActive,
IsBeforeEat = s.a.IsBeforeEat, IsBeforeEat = s.a.IsBeforeEat,

164
src/Shentun.Peis.Application/CollectItemTypes/CollectItemTypeAppService.cs

@ -0,0 +1,164 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shentun.Peis.ColumnReferences;
using Shentun.Peis.HelperDto;
using Shentun.Peis.InvoiceItemTypes;
using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
using Volo.Abp.Users;
namespace Shentun.Peis.CollectItemTypes
{
/// <summary>
/// 汇总项目类别
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class CollectItemTypeAppService : ApplicationService
{
private readonly IRepository<CollectItemType, Guid> _collectItemTypeRepository;
private readonly CollectItemTypeManager _manager;
private readonly CacheService _cacheService;
private readonly IRepository<IdentityUser, Guid> _userRepository;
public CollectItemTypeAppService(
IRepository<CollectItemType, Guid> collectItemTypeRepository,
IRepository<IdentityUser, Guid> userRepository,
CollectItemTypeManager manager)
{
_collectItemTypeRepository = collectItemTypeRepository;
_userRepository = userRepository;
_manager = manager;
}
/// <summary>
/// 根据ID查实体内容
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("api/app/CollectItemType/Get")]
public async Task<CollectItemTypeDto> GetAsync(Guid id)
{
var entity = await _collectItemTypeRepository.GetAsync(id);
var entityDto = ObjectMapper.Map<CollectItemType, CollectItemTypeDto>(entity);
entityDto.CreatorName = _cacheService.GetSurnameAsync(entityDto.CreatorId).Result;
entityDto.LastModifierName = _cacheService.GetSurnameAsync(entityDto.LastModifierId).Result;
return entityDto;
}
/// <summary>
/// 查询列表
/// </summary>
/// <returns></returns>
[HttpPost("api/app/CollectItemType/GetList")]
public async Task<List<CollectItemTypeDto>> GetListAsync()
{
var userQueryable = await _userRepository.GetQueryableAsync();
var entlist = (from a in await _collectItemTypeRepository.GetQueryableAsync()
join b in userQueryable on a.CreatorId equals b.Id into bb
from ab in bb.DefaultIfEmpty()
join c in userQueryable on a.LastModifierId equals c.Id into cc
from ac in cc.DefaultIfEmpty()
select new
{
a,
CreatorName = ab != null ? ab.Surname : "",
LastModifierName = ac != null ? ac.Surname : ""
})
.Select(s => new CollectItemTypeDto
{
CreationTime = s.a.CreationTime,
CreatorId = s.a.CreatorId,
LastModifierId = s.a.LastModifierId,
Id = s.a.Id,
DisplayOrder = s.a.DisplayOrder,
DisplayName = s.a.DisplayName,
InvoiceItemTypeId = s.a.InvoiceItemTypeId,
SimpleCode = s.a.SimpleCode,
LastModificationTime = s.a.LastModificationTime,
CreatorName = s.CreatorName,
LastModifierName = s.LastModifierName
}).OrderBy(o => o.DisplayOrder).ToList();
return entlist;
}
/// <summary>
/// 创建
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/CollectItemType/Create")]
public async Task<CollectItemTypeDto> CreateAsync(CreateCollectItemTypeDto input)
{
var createEntity = ObjectMapper.Map<CreateCollectItemTypeDto, CollectItemType>(input);
var entity = await _manager.CreateAsync(createEntity);
entity = await _collectItemTypeRepository.InsertAsync(entity);
var dto = ObjectMapper.Map<CollectItemType, CollectItemTypeDto>(entity);
return dto;
}
/// <summary>
/// 修改
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/CollectItemType/Update")]
public async Task<CollectItemTypeDto> UpdateAsync(UpdateCollectItemTypeDto input)
{
var entity = await _collectItemTypeRepository.GetAsync(input.Id);
var sourceEntity = ObjectMapper.Map<UpdateCollectItemTypeDto, CollectItemType>(input);
await _manager.UpdateAsync(sourceEntity, entity);
entity = await _collectItemTypeRepository.UpdateAsync(entity);
return ObjectMapper.Map<CollectItemType, CollectItemTypeDto>(entity);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("api/app/CollectItemType/Delete")]
public async Task DeleteAsync(Guid id)
{
var entity = await _collectItemTypeRepository.GetAsync(id);
await _manager.CheckAndDeleteAsync(entity);
}
/// <summary>
/// 修改排序 置顶,置底
/// </summary>
/// <param name="id">需要修改的ID</param>
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
/// <returns></returns>
[HttpPost("api/app/CollectItemType/UpdateManySort")]
public async Task UpdateManySortAsync(Guid id, int SortType)
{
await _manager.UpdateManySortAsync(id, SortType);
}
/// <summary>
/// 修改排序 拖拽
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/CollectItemType/UpdateSortMany")]
public async Task UpdateSortManyAsync(UpdateSortManyDto input)
{
await _manager.UpdateSortManyAsync(input);
}
}
}

7
src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs

@ -6,6 +6,7 @@ using Shentun.Peis.BirthPlaces;
using Shentun.Peis.Books; using Shentun.Peis.Books;
using Shentun.Peis.CardRegisters; using Shentun.Peis.CardRegisters;
using Shentun.Peis.CardTypes; using Shentun.Peis.CardTypes;
using Shentun.Peis.CollectItemTypes;
using Shentun.Peis.ColumnReferences; using Shentun.Peis.ColumnReferences;
using Shentun.Peis.CommonChars; using Shentun.Peis.CommonChars;
using Shentun.Peis.CommonCharTypes; using Shentun.Peis.CommonCharTypes;
@ -456,7 +457,11 @@ public class PeisApplicationAutoMapperProfile : Profile
CreateMap<ThirdInterface, ThirdInterfaceDto>(); CreateMap<ThirdInterface, ThirdInterfaceDto>();
CreateMap<CreateThirdInterfaceDto, ThirdInterface>(); CreateMap<CreateThirdInterfaceDto, ThirdInterface>();
CreateMap<UpdateThirdInterfaceDto, ThirdInterface>(); CreateMap<UpdateThirdInterfaceDto, ThirdInterface>();
CreateMap<CollectItemType, CollectItemTypeDto>();
CreateMap<CreateCollectItemTypeDto, CollectItemType>();
CreateMap<UpdateCollectItemTypeDto, CollectItemType>();
} }
} }

107
src/Shentun.Peis.Domain/CollectItemTypes/CollectItemTypeManager.cs

@ -0,0 +1,107 @@
using Shentun.Peis.Enums;
using Shentun.Peis.HelperDto;
using Shentun.Peis.Models;
using Shentun.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
namespace Shentun.Peis.CollectItemTypes
{
public class CollectItemTypeManager : DomainService
{
private readonly IRepository<CollectItemType, Guid> _repository;
public CollectItemTypeManager(
IRepository<CollectItemType, Guid> repository
)
{
_repository = repository;
}
/// <summary>
/// 创建
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public async Task<CollectItemType> CreateAsync(
CollectItemType entity
)
{
Verify(entity);
await EntityHelper.CheckSameName(_repository, entity.DisplayName);
return new CollectItemType(
GuidGenerator.Create()
)
{
DisplayName = entity.DisplayName,
InvoiceItemTypeId = entity.InvoiceItemTypeId,
SimpleCode = LanguageConverter.GetPYSimpleCode(entity.DisplayName),
DisplayOrder = await EntityHelper.CreateMaxDisplayOrder(_repository)
};
}
public async Task UpdateAsync(
CollectItemType sourceEntity,
CollectItemType targetEntity
)
{
DataHelper.CheckEntityIsNull(targetEntity);
Verify(sourceEntity);
if (sourceEntity.DisplayName != targetEntity.DisplayName)
{
await EntityHelper.CheckSameName<CollectItemType, Guid>(_repository, sourceEntity.DisplayName, targetEntity);
targetEntity.DisplayName = sourceEntity.DisplayName;
targetEntity.SimpleCode = LanguageConverter.GetPYSimpleCode(sourceEntity.DisplayName);
}
targetEntity.InvoiceItemTypeId = sourceEntity.InvoiceItemTypeId;
}
public async Task CheckAndDeleteAsync(CollectItemType entity)
{
await _repository.DeleteAsync(entity);
}
/// <summary>
/// 修改排序 置顶,置底
/// </summary>
/// <param name="id">需要修改的ID</param>
/// <param name="SortType">修改方式:1 置顶 2 置底</param>
/// <returns></returns>
public async Task UpdateManySortAsync(Guid id, int SortType)
{
await EntityHelper.UpdateManySortAsync(_repository, id, SortType);
}
/// <summary>
/// 修改排序 拖拽
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <param name="repository"></param>
/// <param name="input"></param>
/// <returns></returns>
public async Task UpdateSortManyAsync(UpdateSortManyDto input)
{
await EntityHelper.UpdateSortManyAsync(_repository, input);
}
private void Verify(CollectItemType entity)
{
DataHelper.CheckEntityIsNull(entity);
DataHelper.CheckStringIsNull(entity.DisplayName, "名称");
DataHelper.CheckGuidIsDefaultValue(entity.InvoiceItemTypeId, "配置参数");
}
}
}
Loading…
Cancel
Save