|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Volo.Abp.Caching;
|
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts;
|
|
|
|
using Win_in.Sfs.Basedata.Domain;
|
|
|
|
using Win_in.Sfs.Basedata.Domain.Shared;
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Basedata.Application;
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
[Route($"{BasedataConsts.RootPath}purchase-price-sheet")]
|
|
|
|
|
|
|
|
public class PurchasePriceSheetAppService : SfsBaseDataAppServiceBase<PurchasePriceSheet, PurchasePriceSheetDTO, SfsBaseDataRequestInputBase, PurchasePriceSheetEditInput, PurchasePriceSheetImportInput>, IPurchasePriceSheetAppService
|
|
|
|
{
|
|
|
|
private readonly IPurchasePriceSheetRepository _repository;
|
|
|
|
public PurchasePriceSheetAppService(IPurchasePriceSheetRepository repository, IDistributedCache<PurchasePriceSheetDTO> cache) : base(repository, cache)
|
|
|
|
{
|
|
|
|
_repository = repository;
|
|
|
|
base.CreatePolicyName = PurchasePriceSheetPermissions.Create;
|
|
|
|
base.UpdatePolicyName = PurchasePriceSheetPermissions.Update;
|
|
|
|
base.DeletePolicyName = PurchasePriceSheetPermissions.Delete;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 根据供应零件号查询
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="supplierCode"></param>
|
|
|
|
/// <param name="itemCode"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("by-item-code")]
|
|
|
|
public virtual async Task<PurchasePriceSheetDTO> GetByItemCodeAsync(string itemCode,string supplierCode)
|
|
|
|
{
|
|
|
|
var entity = await _repository.FindAsync(p => p.ItemCode== itemCode&&p.SupplierCode== supplierCode).ConfigureAwait(false);
|
|
|
|
var dto = ObjectMapper.Map<PurchasePriceSheet, PurchasePriceSheetDTO>(entity);
|
|
|
|
return dto;
|
|
|
|
}
|
|
|
|
[HttpPost("upsert-interface")]
|
|
|
|
|
|
|
|
public virtual async Task UpsertAsyncByInterface(PurchasePriceSheetEditInput input)
|
|
|
|
{
|
|
|
|
var entity = ObjectMapper.Map<PurchasePriceSheetEditInput, PurchasePriceSheet>(input);
|
|
|
|
await _repository.UpsertAsyncByInterface(entity).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是否有采购价格
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("check-purprice")]
|
|
|
|
public virtual async Task<bool> CheckPurPriceAsync( string supplierCode, string itemCode)
|
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
var entitys = await _repository.GetListAsync(p => p.SupplierCode == supplierCode && p.ItemCode == itemCode).ConfigureAwait(false);
|
|
|
|
if (entitys.Count == 0) result = true;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|