From f94cc53a157497774d5aca99bdea27a77c7bdfbb Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Thu, 2 May 2024 22:07:36 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B1=87=E6=80=BB=E9=A1=B9=E7=9B=AE=E7=B1=BB?=
=?UTF-8?q?=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Asbitems/AsbitemDto.cs | 8 +-
.../Asbitems/CreateAsbitemDto.cs | 4 +-
.../Asbitems/UpdateAsbitemDto.cs | 4 +-
.../CollectItemTypes/CollectItemTypeDto.cs | 27 +++
.../CreateCollectItemTypeDto.cs | 22 +++
.../UpdateCollectItemTypeDto.cs | 23 +++
.../Asbitems/AsbitemAppService.cs | 1 +
.../CollectItemTypeAppService.cs | 164 ++++++++++++++++++
.../PeisApplicationAutoMapperProfile.cs | 7 +-
.../CollectItemTypeManager.cs | 107 ++++++++++++
10 files changed, 358 insertions(+), 9 deletions(-)
create mode 100644 src/Shentun.Peis.Application.Contracts/CollectItemTypes/CollectItemTypeDto.cs
create mode 100644 src/Shentun.Peis.Application.Contracts/CollectItemTypes/CreateCollectItemTypeDto.cs
create mode 100644 src/Shentun.Peis.Application.Contracts/CollectItemTypes/UpdateCollectItemTypeDto.cs
create mode 100644 src/Shentun.Peis.Application/CollectItemTypes/CollectItemTypeAppService.cs
create mode 100644 src/Shentun.Peis.Domain/CollectItemTypes/CollectItemTypeManager.cs
diff --git a/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs b/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs
index 731075c..e9a64a4 100644
--- a/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs
@@ -42,10 +42,10 @@ namespace Shentun.Peis.Asbitems
public Guid? DeviceTypeId { get; set; }
- /////
- ///// 发票类别
- /////
- //public Guid InvoiceItemTypeId { get; set; }
+ ///
+ /// 汇总项目类别ID
+ ///
+ public Guid CollectItemTypeId { get; set; }
///
diff --git a/src/Shentun.Peis.Application.Contracts/Asbitems/CreateAsbitemDto.cs b/src/Shentun.Peis.Application.Contracts/Asbitems/CreateAsbitemDto.cs
index 1500090..b047a65 100644
--- a/src/Shentun.Peis.Application.Contracts/Asbitems/CreateAsbitemDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/Asbitems/CreateAsbitemDto.cs
@@ -40,9 +40,9 @@ namespace Shentun.Peis.Asbitems
///
- /// 发票类别
+ /// 汇总项目类别ID
///
- public Guid InvoiceItemTypeId { get; set; }
+ public Guid CollectItemType { get; set; }
///
diff --git a/src/Shentun.Peis.Application.Contracts/Asbitems/UpdateAsbitemDto.cs b/src/Shentun.Peis.Application.Contracts/Asbitems/UpdateAsbitemDto.cs
index 7461d66..049e319 100644
--- a/src/Shentun.Peis.Application.Contracts/Asbitems/UpdateAsbitemDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/Asbitems/UpdateAsbitemDto.cs
@@ -40,9 +40,9 @@ namespace Shentun.Peis.Asbitems
///
- /// 发票类别
+ /// 汇总项目类别ID
///
- public Guid InvoiceItemTypeId { get; set; }
+ public Guid CollectItemTypeId { get; set; }
///
diff --git a/src/Shentun.Peis.Application.Contracts/CollectItemTypes/CollectItemTypeDto.cs b/src/Shentun.Peis.Application.Contracts/CollectItemTypes/CollectItemTypeDto.cs
new file mode 100644
index 0000000..04cd3b6
--- /dev/null
+++ b/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
+ {
+ ///
+ /// 名称
+ ///
+ public string DisplayName { get; set; }
+
+
+ public string SimpleCode { get; set; }
+
+ ///
+ /// 发票项目类别ID
+ ///
+ public Guid InvoiceItemTypeId { get; set; }
+
+
+ public int DisplayOrder { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/CollectItemTypes/CreateCollectItemTypeDto.cs b/src/Shentun.Peis.Application.Contracts/CollectItemTypes/CreateCollectItemTypeDto.cs
new file mode 100644
index 0000000..a7242ef
--- /dev/null
+++ b/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
+ {
+ ///
+ /// 名称
+ ///
+ public string DisplayName { get; set; }
+
+
+ ///
+ /// 发票项目类别ID
+ ///
+ public Guid InvoiceItemTypeId { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/CollectItemTypes/UpdateCollectItemTypeDto.cs b/src/Shentun.Peis.Application.Contracts/CollectItemTypes/UpdateCollectItemTypeDto.cs
new file mode 100644
index 0000000..ea5f495
--- /dev/null
+++ b/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; }
+
+ ///
+ /// 名称
+ ///
+ public string DisplayName { get; set; }
+
+
+ ///
+ /// 发票项目类别ID
+ ///
+ public Guid InvoiceItemTypeId { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs
index c91014a..e53f327 100644
--- a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs
+++ b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs
@@ -122,6 +122,7 @@ namespace Shentun.Peis.Asbitems
DisplayOrder = s.a.DisplayOrder,
ForSexId = s.a.ForSexId,
Id = s.a.Id,
+ CollectItemTypeId = s.a.CollectItemTypeId,
//InvoiceItemTypeId = s.a.InvoiceItemTypeId,
IsActive = s.a.IsActive,
IsBeforeEat = s.a.IsBeforeEat,
diff --git a/src/Shentun.Peis.Application/CollectItemTypes/CollectItemTypeAppService.cs b/src/Shentun.Peis.Application/CollectItemTypes/CollectItemTypeAppService.cs
new file mode 100644
index 0000000..acae170
--- /dev/null
+++ b/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
+{
+ ///
+ /// 汇总项目类别
+ ///
+ [ApiExplorerSettings(GroupName = "Work")]
+ [Authorize]
+ public class CollectItemTypeAppService : ApplicationService
+ {
+ private readonly IRepository _collectItemTypeRepository;
+ private readonly CollectItemTypeManager _manager;
+ private readonly CacheService _cacheService;
+ private readonly IRepository _userRepository;
+
+ public CollectItemTypeAppService(
+ IRepository collectItemTypeRepository,
+ IRepository userRepository,
+ CollectItemTypeManager manager)
+ {
+ _collectItemTypeRepository = collectItemTypeRepository;
+ _userRepository = userRepository;
+ _manager = manager;
+ }
+
+ ///
+ /// 根据ID查实体内容
+ ///
+ ///
+ ///
+ [HttpPost("api/app/CollectItemType/Get")]
+ public async Task GetAsync(Guid id)
+ {
+ var entity = await _collectItemTypeRepository.GetAsync(id);
+ var entityDto = ObjectMapper.Map(entity);
+ entityDto.CreatorName = _cacheService.GetSurnameAsync(entityDto.CreatorId).Result;
+ entityDto.LastModifierName = _cacheService.GetSurnameAsync(entityDto.LastModifierId).Result;
+
+ return entityDto;
+ }
+
+
+
+ ///
+ /// 查询列表
+ ///
+ ///
+ [HttpPost("api/app/CollectItemType/GetList")]
+ public async Task> 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;
+ }
+
+ ///
+ /// 创建
+ ///
+ ///
+ ///
+ [HttpPost("api/app/CollectItemType/Create")]
+ public async Task CreateAsync(CreateCollectItemTypeDto input)
+ {
+ var createEntity = ObjectMapper.Map(input);
+ var entity = await _manager.CreateAsync(createEntity);
+ entity = await _collectItemTypeRepository.InsertAsync(entity);
+ var dto = ObjectMapper.Map(entity);
+ return dto;
+ }
+
+ ///
+ /// 修改
+ ///
+ ///
+ ///
+ [HttpPost("api/app/CollectItemType/Update")]
+ public async Task UpdateAsync(UpdateCollectItemTypeDto input)
+ {
+ var entity = await _collectItemTypeRepository.GetAsync(input.Id);
+ var sourceEntity = ObjectMapper.Map(input);
+ await _manager.UpdateAsync(sourceEntity, entity);
+ entity = await _collectItemTypeRepository.UpdateAsync(entity);
+ return ObjectMapper.Map(entity);
+ }
+
+ ///
+ /// 删除
+ ///
+ ///
+ ///
+ [HttpPost("api/app/CollectItemType/Delete")]
+ public async Task DeleteAsync(Guid id)
+ {
+ var entity = await _collectItemTypeRepository.GetAsync(id);
+ await _manager.CheckAndDeleteAsync(entity);
+ }
+
+
+ ///
+ /// 修改排序 置顶,置底
+ ///
+ /// 需要修改的ID
+ /// 修改方式:1 置顶 2 置底
+ ///
+ [HttpPost("api/app/CollectItemType/UpdateManySort")]
+ public async Task UpdateManySortAsync(Guid id, int SortType)
+ {
+ await _manager.UpdateManySortAsync(id, SortType);
+ }
+
+ ///
+ /// 修改排序 拖拽
+ ///
+ ///
+ ///
+ [HttpPost("api/app/CollectItemType/UpdateSortMany")]
+ public async Task UpdateSortManyAsync(UpdateSortManyDto input)
+ {
+ await _manager.UpdateSortManyAsync(input);
+ }
+ }
+}
diff --git a/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs b/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
index aa2c955..768d9f3 100644
--- a/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
+++ b/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
@@ -6,6 +6,7 @@ using Shentun.Peis.BirthPlaces;
using Shentun.Peis.Books;
using Shentun.Peis.CardRegisters;
using Shentun.Peis.CardTypes;
+using Shentun.Peis.CollectItemTypes;
using Shentun.Peis.ColumnReferences;
using Shentun.Peis.CommonChars;
using Shentun.Peis.CommonCharTypes;
@@ -456,7 +457,11 @@ public class PeisApplicationAutoMapperProfile : Profile
CreateMap();
CreateMap();
CreateMap();
-
+
+ CreateMap();
+ CreateMap();
+ CreateMap();
+
}
}
diff --git a/src/Shentun.Peis.Domain/CollectItemTypes/CollectItemTypeManager.cs b/src/Shentun.Peis.Domain/CollectItemTypes/CollectItemTypeManager.cs
new file mode 100644
index 0000000..802f338
--- /dev/null
+++ b/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 _repository;
+
+ public CollectItemTypeManager(
+ IRepository repository
+ )
+ {
+ _repository = repository;
+ }
+
+ ///
+ /// 创建
+ ///
+ ///
+ ///
+ public async Task 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(_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);
+ }
+
+ ///
+ /// 修改排序 置顶,置底
+ ///
+ /// 需要修改的ID
+ /// 修改方式:1 置顶 2 置底
+ ///
+ public async Task UpdateManySortAsync(Guid id, int SortType)
+ {
+ await EntityHelper.UpdateManySortAsync(_repository, id, SortType);
+ }
+
+
+
+ ///
+ /// 修改排序 拖拽
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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, "配置参数");
+
+ }
+ }
+}