|
@ -59,250 +59,30 @@ public class EquipmentLocAppService |
|
|
{ |
|
|
{ |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
//public override async Task<IActionResult> ImportAsync([FromForm] SfsImportRequestInput requestInput, [Required] IFormFile file)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// List<EquipmentLocErrorDTO> errors = new List<EquipmentLocErrorDTO>();
|
|
|
|
|
|
// using var ms = new MemoryStream();
|
|
|
|
|
|
// await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false);
|
|
|
|
|
|
// var inputFileBytes = ms.GetAllBytes();
|
|
|
|
|
|
// var dtos=_importService.Import<EquipmentLocEditInput>(inputFileBytes).ToList();
|
|
|
|
|
|
// var list=ObjectMapper.Map<List<EquipmentLocEditInput>, List<EquipmentLoc>>(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<ICategoryAppService>();
|
|
|
|
|
|
//protected IItemCategoryAppService _itemCategoryApp => LazyServiceProvider.LazyGetRequiredService<IItemCategoryAppService>();
|
|
|
|
|
|
|
|
|
|
|
|
//[HttpPost("check")]
|
|
|
|
|
|
//public virtual async Task CheckAsync(string code, EquipmentLocCheckInput input)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var result = new AbpValidationResult();
|
|
|
|
|
|
// _itemValidator.CheckFormat(code);
|
|
|
|
|
|
// var dto = await GetByCodeAsync(code).ConfigureAwait(false);
|
|
|
|
|
|
// var entity = ObjectMapper.Map<EquipmentLocDTO, EquipmentLoc>(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);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
|
///// 检物品状态 是否可用
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
///// <param name="itemCode"></param>
|
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
|
///// <exception cref="NotImplementedException"></exception>
|
|
|
|
|
|
//[HttpGet("check-item-is-available")]
|
|
|
|
|
|
//public virtual async Task<bool> 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;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检物品状态 是否可用(不查询数据库 直接根据对象判断)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="EquipmentLocDTO"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
//[HttpGet("check-item-is-available-no-select-sql")]
|
|
|
|
|
|
//public void CheckItemIsAvailable(EquipmentLocDTO EquipmentLocDTO)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (EquipmentLocDTO != null && EquipmentLocDTO.Status != EnumItemStatus.Active)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// throw new UserFriendlyException($"物料 {EquipmentLocDTO.Code} 状态为 {EquipmentLocDTO.Status} ,不是可用状态");
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//[HttpGet("{id}")]
|
|
|
|
|
|
//public override async Task<EquipmentLocDTO> GetAsync(Guid id)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var dto = await base.GetAsync(id).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
// dto.ItemCategoryDictionary = await GetItemCategory(dto.Code).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
// return dto;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
|
|
//[HttpGet("list-by-name")]
|
|
|
|
|
|
//public virtual async Task<List<EquipmentLocDTO>> GetListByNameAsync(string name)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var entities = await _repository.GetListAsync(c => c.Name == name).ConfigureAwait(false);
|
|
|
|
|
|
// var dtos = ObjectMapper.Map<List<EquipmentLoc>, List<EquipmentLocDTO>>(entities);
|
|
|
|
|
|
// return dtos;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//[HttpGet("get-manage-type")]
|
|
|
|
|
|
//public virtual async Task<EnumItemManageType> 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<Dictionary<string, EnumItemManageType>> GetManageTypesAsync(List<string> 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<EquipmentLocDTO> GetOrAddAsync(EquipmentLocEditInput input)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var result = await _repository.FirstOrDefaultAsync(p => p.Code == input.Code).ConfigureAwait(false);
|
|
|
|
|
|
// if (result == null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input);
|
|
|
|
|
|
// result = await _repository.InsertAsync(entity, true).ConfigureAwait(false);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// var dto = ObjectMapper.Map<EquipmentLoc, EquipmentLocDTO>(result);
|
|
|
|
|
|
// return dto;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//[HttpPost("list")]
|
|
|
|
|
|
//public override async Task<PagedResultDto<EquipmentLocDTO>> GetPagedListByFilterAsync(
|
|
|
|
|
|
// SfsBaseDataRequestInputBase sfsRequestInput,
|
|
|
|
|
|
// bool includeDetails = false,
|
|
|
|
|
|
// CancellationToken cancellationToken = default)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// Expression<Func<EquipmentLoc, bool>> expression = sfsRequestInput.Condition.Filters?.Count > 0
|
|
|
|
|
|
// ? sfsRequestInput.Condition.Filters.ToLambda<EquipmentLoc>()
|
|
|
|
|
|
// : 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(EquipmentLocEditInput input)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input);
|
|
|
|
|
|
// await _repository.UpsertAsync(entity).ConfigureAwait(false);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//[HttpPost("upsert-interface")]
|
|
|
|
|
|
//public virtual async Task UpsertAsyncByInterface(EquipmentLocEditInput input)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input);
|
|
|
|
|
|
// await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//protected override Expression<Func<EquipmentLoc, bool>> BuildSearchExpression(string keyWord)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// Expression<Func<EquipmentLoc, bool>> 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<Dictionary<string, string>> GetItemCategory(string itemCode)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// // var itemCategorys = await this._itemCategoryApp.GetListByItemCode(itemCode).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
// // return itemCategorys.ToDictionary(x => x.CategoryCode, y => y.Value);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost("upsert")] |
|
|
[HttpPost("upsert")] |
|
|
|
|
|
|
|
|
public virtual async Task UpsertAsync(EquipmentLocEditInput input) |
|
|
public virtual async Task UpsertAsync(EquipmentLocEditInput input) |
|
|
{ |
|
|
{ |
|
|
var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input); |
|
|
var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input); |
|
|
|
|
|
|
|
|
await _repository.UpsertAsync(entity).ConfigureAwait(false); |
|
|
await _repository.UpsertAsync(entity).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("")] |
|
|
[Route("")] |
|
|
public override async Task<EquipmentLocDTO> CreateAsync(EquipmentLocEditInput input) |
|
|
public override async Task<EquipmentLocDTO> CreateAsync(EquipmentLocEditInput input) |
|
|
{ |
|
|
{ |
|
|
var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); |
|
|
var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code && p.LocCode==input.LocCode); |
|
|
if (first == null) |
|
|
if (first == null) |
|
|
{ |
|
|
{ |
|
|
var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input); |
|
|
var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input); |
|
|
//entity.Code = string.Format("{0}{1}",entity.Code);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _repository.UpsertAsync(entity).ConfigureAwait(false); |
|
|
await _repository.UpsertAsync(entity).ConfigureAwait(false); |
|
|
var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); |
|
|
var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code); |
|
|
return ObjectMapper.Map<EquipmentLoc,EquipmentLocDTO>(entity1); |
|
|
return ObjectMapper.Map<EquipmentLoc,EquipmentLocDTO>(entity1); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException($"已存在器具编号{input.Code}!"); |
|
|
throw new UserFriendlyException($"已存在器具代码{input.Code}和库位{input.LocCode}关系!"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("GetEquipmentLocs")] |
|
|
[Route("GetEquipmentLocs")] |
|
@ -311,6 +91,5 @@ public class EquipmentLocAppService |
|
|
var query=await _repository.GetQueryableAsync().ConfigureAwait(false); |
|
|
var query=await _repository.GetQueryableAsync().ConfigureAwait(false); |
|
|
var list =query.Where(p => p_ls.Contains(p.Code)); |
|
|
var list =query.Where(p => p_ls.Contains(p.Code)); |
|
|
return ObjectMapper.Map< List<EquipmentLoc> ,List<EquipmentLocDTO>>(list.ToList()); |
|
|
return ObjectMapper.Map< List<EquipmentLoc> ,List<EquipmentLocDTO>>(list.ToList()); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|