You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
3.0 KiB

using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Services;
using Win_in.Sfs.Wms.DataExchange.Application.Contracts.Iac.Mes.Mes;
using Win_in.Sfs.Wms.DataExchange.Application.Contracts.Iac.Mes.Mes.DTOs;
using Win_in.Sfs.Wms.DataExchange.Application.Contracts.Iac.Mes.Mes.Inputs;
using Win_in.Sfs.Wms.DataExchange.Domain.Iac.Mes.MesProductL7PartsNotes;
namespace Win_in.Sfs.Wms.DataExchange.Application.Iac.Mes.Mes;
//[Authorize(IncomingToWmsPermissions.Default)]
//[Route("mes-product-part-note")]
[Route($"{DataExchangeConsts.RouteRoot}mes-product-part")]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.WmsWebApi)]
public class MesProductL7PartsNoteAppService :
ApplicationService, IMesProductL7PartsNoteAppService
{
private readonly IMesProductL7PartsNoteRepository _mesProductL7PartsNoteRepository;
public MesProductL7PartsNoteAppService(
IMesProductL7PartsNoteRepository mesProductL7PartsNoteRepository)
{
_mesProductL7PartsNoteRepository = mesProductL7PartsNoteRepository;
}
/// <summary>
/// 获取上次最大rowid
/// </summary>
/// <returns></returns>
[HttpPost("get-maxid")]
////[Authorize(MesProductL7PartsNotePermissions.CreateAsync)]
public virtual async Task<int> GetMaxRowID()
{
return !(await _mesProductL7PartsNoteRepository.GetQueryableAsync().ConfigureAwait(false)).Any()
? 0
:
//转到实现,保存【L7级零件关系】
(await _mesProductL7PartsNoteRepository.GetQueryableAsync().ConfigureAwait(false)).Max(p => p.RowID);
}
/// <summary>
/// 新增接口
/// </summary>
/// <param name="inputs"></param>
/// <returns></returns>
[HttpPost("add-many")]
public virtual async Task<List<MesProductL7PartsNoteDTO>> AddManyAsync(
List<MesProductL7PartsNoteCreateInput> inputs)
{
//createinput 转化为 domain层的实体
var entities =
ObjectMapper.Map<List<MesProductL7PartsNoteCreateInput>, List<MesProductL7PartsNote>>(inputs);
//添加库存信息具体方法,会自动添加或者更新
await _mesProductL7PartsNoteRepository.InsertManyAsync(entities).ConfigureAwait(false);
//domain层的实体 转化为 显示DTO
var dto = ObjectMapper.Map<List<MesProductL7PartsNote>, List<MesProductL7PartsNoteDTO>>(entities);
return dto;
}
/// <summary>
/// 删除接口
/// </summary>
/// <param name="year"></param>
/// <param name="programCode"></param>
/// <param name="productNo"></param>
/// <returns></returns>
[HttpPost("delete-by-base-info")]
public virtual async Task DeleteByBaseInfoAsync(string year, string programCode, string productNo)
{
//删除对应的实体
await _mesProductL7PartsNoteRepository.DeleteAsync(p =>
p.Year == year && p.Program == programCode && p.ProductNo == productNo).ConfigureAwait(false);
}
}