From 67e282da05eec744044a9434ec7c61900fa8fb3b Mon Sep 17 00:00:00 2001 From: jianghaiqing Date: Tue, 3 Jan 2023 14:47:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=93=81=E5=90=8D=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E5=A2=9E=E3=80=81=E5=88=A0=E3=80=81=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E5=8D=95=E7=A5=A8=E6=9F=A5=E8=AF=A2=E5=92=8C=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Myshipping.Application.xml | 229 ++++++++++++++ .../Service/Para/Dto/ParaContractNoDto.cs | 61 ++++ .../Service/Para/Dto/ParaDtoMapper.cs | 79 +++++ .../Service/Para/Dto/ParaGoodsCategoryDto.cs | 57 ++++ .../Service/Para/Dto/ParaGoodsDto.cs | 85 +++++ .../Service/Para/Interface/IParaService.cs | 82 +++++ .../Service/Para/ParaService.cs | 298 ++++++++++++++++++ 7 files changed, 891 insertions(+) create mode 100644 Myshipping.Application/Service/Para/Dto/ParaContractNoDto.cs create mode 100644 Myshipping.Application/Service/Para/Dto/ParaDtoMapper.cs create mode 100644 Myshipping.Application/Service/Para/Dto/ParaGoodsCategoryDto.cs create mode 100644 Myshipping.Application/Service/Para/Dto/ParaGoodsDto.cs create mode 100644 Myshipping.Application/Service/Para/Interface/IParaService.cs create mode 100644 Myshipping.Application/Service/Para/ParaService.cs diff --git a/Myshipping.Application/Myshipping.Application.xml b/Myshipping.Application/Myshipping.Application.xml index 5f678bb9..4932674f 100644 --- a/Myshipping.Application/Myshipping.Application.xml +++ b/Myshipping.Application/Myshipping.Application.xml @@ -9756,6 +9756,235 @@ 租户ID + + + 主键 + + + + + 合约号编号 + + + + + 合约号名称 + + + + + 合约号备注 + + + + + 创建时间 + + + + + 更新时间 + + + + + 创建者Id + + + + + 创建者名称 + + + + + 修改者Id + + + + + 修改者名称 + + + + + 主键 + + + + + 品名分类代码 + + + + + 品名分类名称 + + + + + 创建时间 + + + + + 更新时间 + + + + + 创建者Id + + + + + 创建者名称 + + + + + 修改者Id + + + + + 修改者名称 + + + + + 主键 + + 358942162968645 + + + + 品名编码 + + HJ1 + + + + 品名中文 + + 红酒 + + + + 品名英文 + + wine + + + + 品名描述 + + 红酒500ml + + + + 品名分类 + + 02 + + + + 品名分类名称 + + 红酒 + + + + 创建时间 + + + + + 更新时间 + + + + + 创建者Id + + + + + 创建者名称 + + + + + 修改者Id + + + + + 修改者名称 + + + + + 保存品名参数 + + 品名参数 + 返回回执 + + + + 作废品名参数 + + 品名参数主键数组 + 返回回执 + + + + 主键获取品名参数 + + 品名主键 + 返回回执 + + + + 检索品名参数 + + 检索值 + 返回回执 + + + + + + + + + 保存品名参数 + + 品名参数 + 返回回执 + + + + 作废品名参数 + + 品名参数主键数组 + 返回回执 + + + + 主键获取品名参数 + + 品名主键 + 返回回执 + + + + 检索品名参数 + + 检索值 + 默认最大行数 + 返回回执 + 件数 diff --git a/Myshipping.Application/Service/Para/Dto/ParaContractNoDto.cs b/Myshipping.Application/Service/Para/Dto/ParaContractNoDto.cs new file mode 100644 index 00000000..802bf475 --- /dev/null +++ b/Myshipping.Application/Service/Para/Dto/ParaContractNoDto.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class ParaContractNoDto + { + /// + /// 主键 + /// + public string Id{ get; set; } + + /// + /// 合约号编号 + /// + public string ContractNo { get; set; } + + /// + /// 合约号名称 + /// + public string ContractName { get; set; } + + /// + /// 合约号备注 + /// + public string ContractNote { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long CreateUserId { get; set; } + + /// + /// 创建者名称 + /// + public string CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long UpdateUserId { get; set; } + + /// + /// 修改者名称 + /// + public string UpdateUserName { get; set; } + } +} diff --git a/Myshipping.Application/Service/Para/Dto/ParaDtoMapper.cs b/Myshipping.Application/Service/Para/Dto/ParaDtoMapper.cs new file mode 100644 index 00000000..e0dd2320 --- /dev/null +++ b/Myshipping.Application/Service/Para/Dto/ParaDtoMapper.cs @@ -0,0 +1,79 @@ +using Mapster; +using Myshipping.Application.Entity; +using StackExchange.Profiling.Internal; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class ParaDtoMapper : IRegister + { + public void Register(TypeAdapterConfig config) + { + config.ForType() + .Map(dest => dest.Id, src => src.Id) + .Map(dest => dest.GoodsCode, src => src.GOODS_CODE) + .Map(dest => dest.GoodsNameCN, src => src.GOODS_NAME_CN) + .Map(dest => dest.GoodsNameEN, src => src.GOODS_NAME_EN) + .Map(dest => dest.GoodsDesp, src => src.GOODS_DESP) + .Map(dest => dest.GoodsCategory, src => src.GOODS_CATEGORY) + .Map(dest => dest.GoodsCategoryName, src => src.GOODS_CATEGORY_NAME) + .Map(dest => dest.CreateUserId, src => src.CreatedUserId) + .Map(dest => dest.CreateUserName, src => src.CreatedUserName) + .Map(dest => dest.CreateTime, src => src.CreatedTime) + .Map(dest => dest.UpdateUserId, src => src.UpdatedUserId) + .Map(dest => dest.UpdateUserName, src => src.UpdatedUserName) + .Map(dest => dest.UpdateTime, src => src.UpdatedTime); + + config.ForType() + .Map(dest => dest.Id, src => !string.IsNullOrWhiteSpace(src.Id) ? long.Parse(src.Id) : 0) + .Map(dest => dest.GOODS_CODE, src => src.GoodsCode) + .Map(dest => dest.GOODS_NAME_CN, src => src.GoodsNameCN) + .Map(dest => dest.GOODS_NAME_EN, src => src.GoodsNameEN) + .Map(dest => dest.GOODS_DESP, src => src.GoodsDesp) + .Map(dest => dest.GOODS_CATEGORY, src => src.GoodsCategory) + .Map(dest => dest.GOODS_CATEGORY_NAME, src => src.GoodsCategoryName); + + + config.ForType() + .Map(dest => dest.Id, src => src.Id) + .Map(dest => dest.GoodsCategory, src => src.GOODS_CATEGORY) + .Map(dest => dest.GoodsCategoryName, src => src.GOODS_CATEGORY_NAME) + .Map(dest => dest.CreateUserId, src => src.CreatedUserId) + .Map(dest => dest.CreateUserName, src => src.CreatedUserName) + .Map(dest => dest.CreateTime, src => src.CreatedTime) + .Map(dest => dest.UpdateUserId, src => src.UpdatedUserId) + .Map(dest => dest.UpdateUserName, src => src.UpdatedUserName) + .Map(dest => dest.UpdateTime, src => src.UpdatedTime); + + + config.ForType() + .Map(dest => dest.Id, src => !string.IsNullOrWhiteSpace(src.Id) ? long.Parse(src.Id) : 0) + .Map(dest => dest.GOODS_CATEGORY, src => src.GoodsCategory) + .Map(dest => dest.GOODS_CATEGORY_NAME, src => src.GoodsCategoryName); + + + config.ForType() + .Map(dest => dest.Id, src => src.Id) + .Map(dest => dest.ContractNo, src => src.CONTRACT_NO) + .Map(dest => dest.ContractName, src => src.CONTRACT_NAME) + .Map(dest => dest.ContractNote, src => src.CONTRACT_NOTE) + .Map(dest => dest.CreateUserId, src => src.CreatedUserId) + .Map(dest => dest.CreateUserName, src => src.CreatedUserName) + .Map(dest => dest.CreateTime, src => src.CreatedTime) + .Map(dest => dest.UpdateUserId, src => src.UpdatedUserId) + .Map(dest => dest.UpdateUserName, src => src.UpdatedUserName) + .Map(dest => dest.UpdateTime, src => src.UpdatedTime); + + + config.ForType() + .Map(dest => dest.Id, src => !string.IsNullOrWhiteSpace(src.Id) ? long.Parse(src.Id) : 0) + .Map(dest => dest.CONTRACT_NO, src => src.ContractNo) + .Map(dest => dest.CONTRACT_NAME, src => src.ContractName) + .Map(dest => dest.CONTRACT_NOTE, src => src.ContractNote); + } + } +} diff --git a/Myshipping.Application/Service/Para/Dto/ParaGoodsCategoryDto.cs b/Myshipping.Application/Service/Para/Dto/ParaGoodsCategoryDto.cs new file mode 100644 index 00000000..911318d7 --- /dev/null +++ b/Myshipping.Application/Service/Para/Dto/ParaGoodsCategoryDto.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class ParaGoodsCategoryDto + { + /// + /// 主键 + /// + public string Id { get; set; } + + + /// + /// 品名分类代码 + /// + public string GoodsCategory { get; set; } + + /// + /// 品名分类名称 + /// + public string GoodsCategoryName { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long CreateUserId { get; set; } + + /// + /// 创建者名称 + /// + public string CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long UpdateUserId { get; set; } + + /// + /// 修改者名称 + /// + public string UpdateUserName { get; set; } + } +} diff --git a/Myshipping.Application/Service/Para/Dto/ParaGoodsDto.cs b/Myshipping.Application/Service/Para/Dto/ParaGoodsDto.cs new file mode 100644 index 00000000..d4488546 --- /dev/null +++ b/Myshipping.Application/Service/Para/Dto/ParaGoodsDto.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public class ParaGoodsDto + { + /// + /// 主键 + /// + /// 358942162968645 + public string Id { get; set; } + + /// + /// 品名编码 + /// + /// HJ1 + [Required(ErrorMessage = "品名编码不能为空")] + public string GoodsCode { get; set; } + + /// + /// 品名中文 + /// + /// 红酒 + public string GoodsNameCN { get; set; } + + /// + /// 品名英文 + /// + /// wine + public string GoodsNameEN { get; set; } + + /// + /// 品名描述 + /// + /// 红酒500ml + public string GoodsDesp { get; set; } + + /// + /// 品名分类 + /// + /// 02 + public string GoodsCategory { get; set; } + + /// + /// 品名分类名称 + /// + /// 红酒 + public string GoodsCategoryName { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } + + /// + /// 更新时间 + /// + public DateTime UpdateTime { get; set; } + + /// + /// 创建者Id + /// + public long CreateUserId { get; set; } + + /// + /// 创建者名称 + /// + public string CreateUserName { get; set; } + + /// + /// 修改者Id + /// + public long UpdateUserId { get; set; } + + /// + /// 修改者名称 + /// + public string UpdateUserName { get; set; } + } +} diff --git a/Myshipping.Application/Service/Para/Interface/IParaService.cs b/Myshipping.Application/Service/Para/Interface/IParaService.cs new file mode 100644 index 00000000..41f548d9 --- /dev/null +++ b/Myshipping.Application/Service/Para/Interface/IParaService.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + public interface IParaService + { + /// + /// 保存品名参数 + /// + /// 品名参数 + /// 返回回执 + Task SaveParaGoodsInfo(ParaGoodsDto model); + + /// + /// 作废品名参数 + /// + /// 品名参数主键数组 + /// 返回回执 + Task DeleteParaGoodsInfo(long[] Ids); + + /// + /// 主键获取品名参数 + /// + /// 品名主键 + /// 返回回执 + Task GetParaGoodsInfo(long Id); + + /// + /// 检索品名参数 + /// + /// 检索值 + /// 返回回执 + Task> QueryParaGoodsInfo(string queryItem, int top = 10); + + ///// + ///// 保存品名分类参数 + ///// + ///// 品名分类参数 + ///// 返回回执 + //Task SaveParaGoodsCategoryInfo(ParaGoodsCategoryDto model); + + ///// + ///// 主键获取品名分类参数 + ///// + ///// 品名分类主键 + ///// 返回回执 + //Task GetParaGoodsCategoryInfo(long Id); + + ///// + ///// 检索品名分类参数 + ///// + ///// 检索值 + ///// 返回回执 + //Task QueryParaGoodsCategoryInfo(string queryItem); + + + ///// + ///// 保存约号参数 + ///// + ///// 约号参数 + ///// 返回回执 + //Task SaveParaContractNoInfo(ParaGoodsCategoryDto model); + + ///// + ///// 主键获取约号参数 + ///// + ///// 约号主键 + ///// 返回回执 + //Task GetParaContractNoInfo(long Id); + + ///// + ///// 检索约号参数 + ///// + ///// 检索值 + ///// 返回回执 + //Task QuerytParaContractNoInfo(string queryItem); + } +} diff --git a/Myshipping.Application/Service/Para/ParaService.cs b/Myshipping.Application/Service/Para/ParaService.cs new file mode 100644 index 00000000..dffdc66d --- /dev/null +++ b/Myshipping.Application/Service/Para/ParaService.cs @@ -0,0 +1,298 @@ +using Furion.DynamicApiController; +using Furion.FriendlyException; +using Furion.Templates; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Myshipping.Application.Entity; +using Myshipping.Core; +using NPOI.OpenXmlFormats.Wordprocessing; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application +{ + /// + /// + /// + [ApiDescriptionSettings("Application", Name = "Para", Order = 10)] + public class ParaService : IParaService, IDynamicApiController + { + private readonly SqlSugarRepository _paraGoodsInfoRepository; + private readonly SqlSugarRepository _paraGoodsCategoryInfoRepository; + private readonly SqlSugarRepository _paraContractNoInfoRepository; + private readonly ILogger _logger; + + public ParaService(SqlSugarRepository paraGoodsInfoRepository, + SqlSugarRepository paraGoodsCategoryInfoRepository, + SqlSugarRepository paraContractNoInfoRepository, + ILogger logger + + ) + { + _paraGoodsInfoRepository = paraGoodsInfoRepository; + _paraGoodsCategoryInfoRepository = paraGoodsCategoryInfoRepository; + _paraContractNoInfoRepository = paraContractNoInfoRepository; + + _logger = logger; + } + /// + /// 保存品名参数 + /// + /// 品名参数 + /// 返回回执 + [HttpPost("/Para/SaveParaGoodsInfo")] + public async Task SaveParaGoodsInfo(ParaGoodsDto model) + { + ParaGoodsInfo info = null; + + try + { + //判断代码不能重复 + var sameList = _paraGoodsInfoRepository.AsQueryable() + .Where(t => t.GOODS_CODE.Equals(model.GoodsCode, StringComparison.OrdinalIgnoreCase)).ToList(); + + if(sameList.Count > 0 && !string.IsNullOrWhiteSpace(model.Id) && sameList.Any(t=>t.Id != long.Parse(model.Id))) + throw Oops.Oh($"商品编码【{model.GoodsCode}】已存在不能重复保存"); + + + if (!string.IsNullOrWhiteSpace(model.Id)) + { + info = await _paraGoodsInfoRepository.AsQueryable().FirstAsync(t => t.Id == long.Parse(model.Id)); + + info.GOODS_CODE = model.GoodsCode; + info.GOODS_NAME_CN = model.GoodsNameCN; + info.GOODS_NAME_EN = model.GoodsNameEN; + info.GOODS_DESP = model.GoodsDesp; + info.GOODS_CATEGORY = model.GoodsCategory; + info.GOODS_CATEGORY_NAME = model.GoodsCategoryName; + + await _paraGoodsInfoRepository.AsUpdateable(info).IgnoreColumns(it => new + { + it.Id, + it.TenantId, + it.CreatedTime, + it.CreatedUserId, + it.CreatedUserName + }).ExecuteCommandAsync(); + } + else + { + info = model.Adapt(); + + await _paraGoodsInfoRepository.InsertAsync(info); + } + } + catch (Exception ex) + { + throw Oops.Bah($"保存品名参数异常,{ex.Message}"); + } + + return info.Id; + } + + /// + /// 作废品名参数 + /// + /// 品名参数主键数组 + /// 返回回执 + [HttpPost("/Para/DeleteParaGoodsInfo")] + public async Task DeleteParaGoodsInfo([FromBody] long[] Ids) + { + try + { + //如果没有给主键直接抛异常 + if (Ids.Length == 0) + throw Oops.Oh("没有提供需要作废的主键信息"); + + var list = _paraGoodsInfoRepository.AsQueryable().Where(t => Ids.Contains(t.Id)).ToList(); + + if (list.Count != Ids.Length) + { + var noRecord = string.Join(",", Ids.GroupJoin(list, l => l, r => r.Id, (l, r) => { + var currList = r.ToList(); + + if (r.Count() > 0) + return string.Empty; + + return l.ToString(); + }).Where(t => !string.IsNullOrWhiteSpace(t)).ToArray()); + + throw Oops.Oh($"以下主键信息 {noRecord} 检索失败或者已作废过"); + } + + list.ForEach(async entity => + { + entity.IsDeleted = true; + entity.UpdatedTime = DateTime.Now; + entity.UpdatedUserId = UserManager.UserId; + entity.UpdatedUserName = UserManager.Name; + + await _paraGoodsInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new + { + it.Id, + it.TenantId, + it.CreatedTime, + it.CreatedUserId, + it.CreatedUserName + }).ExecuteCommandAsync(); + }); + + } + catch (Exception ex) + { + throw Oops.Bah($"作废品名参数异常,{ex.Message}"); + } + + return "作废成功"; + } + + /// + /// 主键获取品名参数 + /// + /// 品名主键 + /// 返回回执 + [HttpGet("/Para/GetParaGoodsInfo")] + public async Task GetParaGoodsInfo([FromQuery]long Id) + { + ParaGoodsDto model = null; + + try + { + ParaGoodsInfo info = _paraGoodsInfoRepository.AsQueryable().First(t => t.Id == Id); + + if(info == null) + throw Oops.Oh($"获取品名参数失败"); + + + model = info.Adapt(); + + } + catch (Exception ex) + { + throw Oops.Bah($"获取品名参数异常,{ex.Message}"); + } + + return model; + } + + /// + /// 检索品名参数 + /// + /// 检索值 + /// 默认最大行数 + /// 返回回执 + [HttpGet("/Para/QueryParaGoodsInfo")] + public async Task> QueryParaGoodsInfo([FromQuery] string queryItem, [FromQuery] int top = 10) + { + List list = new List(); + + try + { + var query = _paraGoodsInfoRepository.AsQueryable(); + + if (!string.IsNullOrWhiteSpace(queryItem)) + { + query = query.Where(t => t.GOODS_CODE.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) || + t.GOODS_NAME_CN.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) || + t.GOODS_NAME_EN.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) || + t.GOODS_DESP.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) || + t.GOODS_CATEGORY.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) || + t.GOODS_CATEGORY_NAME.Contains(queryItem.Trim(), StringComparison.OrdinalIgnoreCase) + ); + } + + query = query.OrderBy("GOODS_CODE asc"); + + var goodsList = await query.Take(top).ToListAsync(); + + if (goodsList.Count > 0) + list = goodsList.Select(t => t.Adapt()).ToList(); + + } + catch (Exception ex) + { + throw Oops.Bah($"保存品名参数异常,{ex.Message}"); + } + + return list; + } + + ///// + ///// 保存品名分类参数 + ///// + ///// 品名分类参数 + ///// 返回回执 + //public async Task SaveParaGoodsCategoryInfo(ParaGoodsCategoryDto model) + //{ + // CommonWebApiResult result = new CommonWebApiResult(); + + // return result; + //} + + ///// + ///// 主键获取品名分类参数 + ///// + ///// 品名分类主键 + ///// 返回回执 + //public async Task GetParaGoodsCategoryInfo(long Id) + //{ + // CommonWebApiResult result = new CommonWebApiResult(); + + // return result; + //} + + ///// + ///// 检索品名分类参数 + ///// + ///// 检索值 + ///// 返回回执 + //public async Task QueryParaGoodsCategoryInfo(string queryItem) + //{ + // CommonWebApiResult result = new CommonWebApiResult(); + + // return result; + //} + + + ///// + ///// 保存约号参数 + ///// + ///// 约号参数 + ///// 返回回执 + //public async Task SaveParaContractNoInfo(ParaGoodsCategoryDto model) + //{ + // CommonWebApiResult result = new CommonWebApiResult(); + + // return result; + //} + + ///// + ///// 主键获取约号参数 + ///// + ///// 约号主键 + ///// 返回回执 + //public async Task GetParaContractNoInfo(long Id) + //{ + // CommonWebApiResult result = new CommonWebApiResult(); + + // return result; + //} + + ///// + ///// 检索约号参数 + ///// + ///// 检索值 + ///// 返回回执 + //public async Task QuerytParaContractNoInfo(string queryItem) + //{ + // CommonWebApiResult result = new CommonWebApiResult(); + + // return result; + //} + } +}