|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Volo.Abp;
|
|
|
|
using Volo.Abp.Application.Dtos;
|
|
|
|
using Volo.Abp.Caching;
|
|
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
|
using Volo.Abp.Validation;
|
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts;
|
|
|
|
using Win_in.Sfs.Basedata.Domain;
|
|
|
|
using Win_in.Sfs.Basedata.Domain.Shared;
|
|
|
|
using Win_in.Sfs.Shared.Application.Contracts;
|
|
|
|
using Win_in.Sfs.Shared.Application.Contracts.ExportAndImport;
|
|
|
|
using Win_in.Sfs.Shared.Domain;
|
|
|
|
using Win_in.Sfs.Shared.Domain.Shared;
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Basedata.Application;
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
[Route($"{BasedataConsts.RootPath}EquipmentLoc")]
|
|
|
|
public class EquipmentLocAppService
|
|
|
|
: SfsBaseDataWithCodeAppServiceBase<EquipmentLoc, EquipmentLocDTO, SfsBaseDataRequestInputBase, EquipmentLocEditInput, EquipmentLocImportInput>
|
|
|
|
, IEquipmentLocAppService
|
|
|
|
{
|
|
|
|
//private readonly ItemValidator _itemValidator;
|
|
|
|
private readonly IEquipmentLocManager _manager;
|
|
|
|
private new readonly IEquipmentLocRepository _repository;
|
|
|
|
private readonly IExportImportService _importService;
|
|
|
|
|
|
|
|
public EquipmentLocAppService(
|
|
|
|
IEquipmentLocRepository repository,
|
|
|
|
IDistributedCache<EquipmentLocDTO> cache,
|
|
|
|
IExportImportService importService,
|
|
|
|
// ItemValidator itemValidator,
|
|
|
|
IEquipmentLocManager manager)
|
|
|
|
: base(repository, cache)
|
|
|
|
{
|
|
|
|
_importService=importService;
|
|
|
|
_repository = repository;
|
|
|
|
//_itemValidator = itemValidator;
|
|
|
|
_manager = manager;
|
|
|
|
base.CreatePolicyName = EquipmentPermissions.Create;
|
|
|
|
base.UpdatePolicyName = EquipmentPermissions.Update;
|
|
|
|
base.DeletePolicyName = EquipmentPermissions.Delete;
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpPost("check")]
|
|
|
|
//[Authorize(ErpLocationPermissions.Default)]
|
|
|
|
|
|
|
|
public virtual async Task CheckAsync(string code, EquipmentLocCheckInput input)
|
|
|
|
{
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
[HttpPost("upsert")]
|
|
|
|
|
|
|
|
public virtual async Task UpsertAsync(EquipmentLocEditInput input)
|
|
|
|
{
|
|
|
|
var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input);
|
|
|
|
await _repository.UpsertAsync(entity).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
|
|
[Route("")]
|
|
|
|
public override async Task<EquipmentLocDTO> CreateAsync(EquipmentLocEditInput input)
|
|
|
|
{
|
|
|
|
var first= _repository.WithDetails().FirstOrDefault(p => p.Code == input.Code && p.LocCode==input.LocCode);
|
|
|
|
if (first == null)
|
|
|
|
{
|
|
|
|
var entity = ObjectMapper.Map<EquipmentLocEditInput, EquipmentLoc>(input);
|
|
|
|
await _repository.UpsertAsync(entity).ConfigureAwait(false);
|
|
|
|
var entity1=_repository.WithDetails().FirstOrDefault(p => p.Code == input.Code);
|
|
|
|
return ObjectMapper.Map<EquipmentLoc,EquipmentLocDTO>(entity1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new UserFriendlyException($"已存在器具代码{input.Code}和库位{input.LocCode}关系!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
|
|
[Route("GetEquipmentLocs")]
|
|
|
|
public async Task<List<EquipmentLocDTO>> GetEquipmentLocAsync(List<string> p_ls)
|
|
|
|
{
|
|
|
|
var query=await _repository.GetQueryableAsync().ConfigureAwait(false);
|
|
|
|
var list =query.Where(p => p_ls.Contains(p.Code));
|
|
|
|
return ObjectMapper.Map< List<EquipmentLoc> ,List<EquipmentLocDTO>>(list.ToList());
|
|
|
|
}
|
|
|
|
}
|