98 lines
3.0 KiB
98 lines
3.0 KiB
3 years ago
|
using Microsoft.AspNetCore.Authorization;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel.DataAnnotations;
|
||
|
using System.Linq;
|
||
|
using System.Text.Json;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Threading.Tasks.Dataflow;
|
||
|
using AutoMapper;
|
||
|
using AutoMapper.Configuration;
|
||
|
using FluentValidation;
|
||
|
using Microsoft.EntityFrameworkCore;
|
||
|
using Volo.Abp.Application.Dtos;
|
||
|
using Volo.Abp.Application.Services;
|
||
|
using Volo.Abp.Domain.Repositories;
|
||
|
using Volo.Abp.Uow;
|
||
|
using Win_in.Sfs.Scp.v1.Domain;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
using Volo.Abp.Clients;
|
||
|
using Volo.Abp.MultiTenancy;
|
||
|
using Volo.Abp.Validation;
|
||
|
using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
|
||
|
using Volo.Abp.TenantManagement;
|
||
|
using Win_in.Sfs.Scp.WebApi.Asns;
|
||
|
|
||
|
namespace Win_in.Sfs.Scp.WebApi
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 零件服务
|
||
|
/// </summary>
|
||
|
[Authorize]
|
||
|
[Route(RouteConsts.X12Asn)]
|
||
|
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
|
||
|
|
||
|
public class X12AsnAppService : ReadOnlyAppService<X12Asn, X12AsnDTO, Guid, RequestDTO>, IX12AsnAppService
|
||
|
{
|
||
|
private readonly IX12AsnRepository _x12AsnRepository;
|
||
|
private readonly ITenantStore _tenantStore;
|
||
|
private readonly ITenantRepository _tenantRepository;
|
||
|
|
||
|
public X12AsnAppService(
|
||
|
IX12AsnRepository repository
|
||
|
, ITenantStore tenantStore
|
||
|
, ITenantRepository tenantRepository
|
||
|
) : base(repository)
|
||
|
{
|
||
|
_x12AsnRepository = repository;
|
||
|
_tenantStore = tenantStore;
|
||
|
_tenantRepository = tenantRepository;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 按ID获取零件 (Get X12Asn by ID)
|
||
|
/// </summary>
|
||
|
/// <param name="id">唯一ID(unique ID)</param>
|
||
|
/// <returns></returns>
|
||
|
|
||
|
[HttpGet]
|
||
|
[Route("{id}")]
|
||
|
public override async Task<X12AsnDTO> GetAsync(Guid id)
|
||
|
{
|
||
|
return await base.GetAsync(id);
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 按条件获取零件列表 (Get X12Asn list by request condition)
|
||
|
/// </summary>
|
||
|
/// <param name="requestDTO">请求条件DTO(Request condition DTO)</param>
|
||
|
/// <returns></returns>
|
||
|
[HttpGet]
|
||
|
[Route("")]
|
||
|
public override async Task<PagedResultDto<X12AsnDTO>> GetListAsync(RequestDTO requestDTO)
|
||
|
{
|
||
|
return await base.GetListAsync(requestDTO);
|
||
|
}
|
||
|
|
||
|
public async Task<ListResultDto<X12AsnDTO>> GetUnreadListAsync(int count)
|
||
|
{
|
||
|
var entities = await _x12AsnRepository.GetUnreadListAsync(count);
|
||
|
|
||
|
var dtos = entities.Select(entity => new X12AsnDTO()
|
||
|
{
|
||
|
Id = entity.Id,
|
||
|
UID = entity.UID,
|
||
|
BillNum = entity.BillNum,
|
||
|
Remark = entity.Remark,
|
||
|
AsnX12 = JsonSerializer.Deserialize<ASN_X12_856_3060>(entity.DataContent)
|
||
|
})
|
||
|
.ToList();
|
||
|
|
||
|
return new ListResultDto<X12AsnDTO>(dtos);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|