diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs index 13e5b4d5e..ffccac6cd 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Equipments/EquipmentPartCodeAppService.cs @@ -59,220 +59,6 @@ public class EquipmentPartCodeAppService { await Task.CompletedTask.ConfigureAwait(false); } - //public override async Task ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file) - //{ - // List errors = new List(); - // using var ms = new MemoryStream(); - // await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); - // var inputFileBytes = ms.GetAllBytes(); - // var dtos=_importService.Import(inputFileBytes).ToList(); - // var list=ObjectMapper.Map, List>(dtos); - - - - - - // foreach (var itm in list) - // { - // itm.SetId(GuidGenerator.Create()); - // itm.Code = string.Format("{0}{1}", "Q", itm.Code); - - // } - - - - - // ////var bytes = result.FileContents; - // ////result.FileContents = null; - - // ////HttpContextAccessor.HttpContext.Response.Headers.AccessControlExposeHeaders = "X-Response"; - // ////HttpContextAccessor.HttpContext.Response.Headers.Add("X-Response", - // //// JsonSerializer.Serialize(new { result.ExceptionMessage, result.FileName, result.FileCode, result })); - - // ////Console.WriteLine(@"导入错误信息:" + result.ExceptionMessage); - - // ////var resultAction = new TestResult(bytes, ExportImportService.ContentType) { FileDownloadName = result.FileName }; - // ////resultAction.errorNum = result.ErrorNum; - // ////resultAction.successNum = resultAction.successNum; - // //return resultAction; - - - - - - - - - // // return base.ImportAsync(requestInput, file); - //} - - //protected ICategoryAppService _categoryApp => LazyServiceProvider.LazyGetRequiredService(); - //protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService(); - - //[HttpPost("check")] - //public virtual async Task CheckAsync(string code, EquipmentPartCodeCheckInput input) - //{ - // var result = new AbpValidationResult(); - // _itemValidator.CheckFormat(code); - // var dto = await GetByCodeAsync(code).ConfigureAwait(false); - // var entity = ObjectMapper.Map(dto); - // //_itemValidator.CheckCanBuy(entity, input.CanBuy, result); - // //_itemValidator.CheckCanMake(entity, input.CanMake, result); - // //_itemValidator.CheckStatus(entity, input.Statuses, result); - // //_itemValidator.CheckProject(entity, input.Projects, result); - // //await _itemValidator.CheckCategoryAsync(entity, input.Categories, result).ConfigureAwait(false); - // if (result.Errors.Count > 0) - // { - // throw new AbpValidationException(result.Errors); - // } - //} - - ///// - ///// 检物品状态 是否可用 - ///// - ///// - ///// - ///// - //[HttpGet("check-item-is-available")] - //public virtual async Task CheckItemIsAvailable(string itemCode) - //{ - // var entity = await _repository.FindAsync(c => c.Code == itemCode).ConfigureAwait(false); - - // if (entity == null) - // { - // throw new UserFriendlyException($"未找到代码为 {itemCode} 的物品"); - // } - - // return entity.Status == EnumItemStatus.Active; - //} - - /// - /// 检物品状态 是否可用(不查询数据库 直接根据对象判断) - /// - /// - /// - //[HttpGet("check-item-is-available-no-select-sql")] - //public void CheckItemIsAvailable(EquipmentPartCodeDTO EquipmentPartCodeDTO) - //{ - // if (EquipmentPartCodeDTO != null && EquipmentPartCodeDTO.Status != EnumItemStatus.Active) - // { - // throw new UserFriendlyException($"物料 {EquipmentPartCodeDTO.Code} 状态为 {EquipmentPartCodeDTO.Status} ,不是可用状态"); - // } - //} - - //[HttpGet("{id}")] - //public override async Task GetAsync(Guid id) - //{ - // var dto = await base.GetAsync(id).ConfigureAwait(false); - - // dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false); - - // return dto; - //} - - /// - /// - /// - /// - /// - /// - //[HttpGet("list-by-name")] - //public virtual async Task> GetListByNameAsync(string name) - //{ - // var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false); - // var dtos = ObjectMapper.Map, List>(entities); - // return dtos; - //} - - //[HttpGet("get-manage-type")] - //public virtual async Task GetManageTypeAsync(string itemCode) - //{ - // var entity = await GetByCodeAsync(itemCode).ConfigureAwait(false); - // Check.NotNull(entity, "物品代码", $"物品 {itemCode} 不存在"); - // return entity.ManageType; - //} - - //[HttpGet("get-manage-types")] - //public virtual async Task> GetManageTypesAsync(List itemCodes) - //{ - // var dtos = await GetByCodesAsync(itemCodes).ConfigureAwait(false); - // var itemManageTypes = dtos.ToDictionary(dto => dto.Code, dto => dto.ManageType); - // return itemManageTypes; - //} - - //[HttpPost("get-or-add")] - //public virtual async Task GetOrAddAsync(EquipmentPartCodeEditInput input) - //{ - // var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false); - // if (result == null) - // { - // var entity = ObjectMapper.Map(input); - // result = await _repository.InsertAsync(entity, true).ConfigureAwait(false); - // } - - // var dto = ObjectMapper.Map(result); - // return dto; - //} - - //[HttpPost("list")] - //public override async Task> GetPagedListByFilterAsync( - // SfsBaseDataRequestInputBase sfsRequestInput, - // bool includeDetails = false, - // CancellationToken cancellationToken = default) - //{ - // Expression> expression = sfsRequestInput.Condition.Filters?.Count > 0 - // ? sfsRequestInput.Condition.Filters.ToLambda() - // : p => true; - // var pageResult = await GetPagedListAsync( - // expression, - // sfsRequestInput.SkipCount, - // sfsRequestInput.MaxResultCount, - // sfsRequestInput.Sorting, - // includeDetails, - // cancellationToken).ConfigureAwait(false); - - // foreach (var item in pageResult.Items) - // { - // item.ItemCategoryDictionary = await GetItemCategory(item.Code).ConfigureAwait(false); - // } - - // return pageResult; - //} - - //[HttpPost("upsert")] - //public virtual async Task UpsertAsync(EquipmentPartCodeEditInput input) - //{ - // var entity = ObjectMapper.Map(input); - // await _repository.UpsertAsync(entity).ConfigureAwait(false); - //} - //[HttpPost("upsert-interface")] - //public virtual async Task UpsertAsyncByInterface(EquipmentPartCodeEditInput input) - //{ - // var entity = ObjectMapper.Map(input); - // await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false); - //} - - //protected override Expression> BuildSearchExpression(string keyWord) - //{ - // Expression> expression = p => - // p.Code.Contains(keyWord) - // || p.Name.Contains(keyWord) - // || p.Desc1.Contains(keyWord) - // || p.Desc2.Contains(keyWord) - // || p.AbcClass.Contains(keyWord) - // || p.BasicUom.Contains(keyWord) - // || p.Elevel.Contains(keyWord) - // || p.Project.Contains(keyWord) - // || p.Version.Contains(keyWord); - // return expression; - //} - - //private async Task> GetItemCategory(string itemCode) - //{ - // // var itemCategorys = await this._itemCategoryApp.GetListByItemCode(itemCode).ConfigureAwait(false); - - // // return itemCategorys.ToDictionary(x => x.CategoryCode, y => y.Value); - //} [HttpPost("upsert")] @@ -287,7 +73,7 @@ public class EquipmentPartCodeAppService [Route("")] public override async Task CreateAsync(EquipmentPartCodeEditInput input) { - var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); + var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code && p.PartCode==input.PartCode); if (first == null) { var entity = ObjectMapper.Map(input); @@ -298,9 +84,8 @@ public class EquipmentPartCodeAppService } else { - throw new UserFriendlyException($"已存在器具编号{input.Code}!"); + throw new UserFriendlyException($"已存在器具代码{input.Code}和零件代码{input.PartCode}关系!"); } - } [HttpPost] [Route("GetEquipmentPartCodes")] @@ -312,6 +97,12 @@ public class EquipmentPartCodeAppService return ObjectMapper.Map, List>(list.ToList()); } + protected override async Task ValidateImportModelAsync(EquipmentPartCodeImportInput importInput, List validationRresult) + { + await base.CheckItemBasicItemCodeAsync(importInput.Code, validationRresult).ConfigureAwait(false); + + // await base.CheckComponentAndComponentQtyAsync(importInput.Component, importInput.ComponentQty, validationRresult).ConfigureAwait(false); + }