85 lines
3.1 KiB
C#
Executable File
85 lines
3.1 KiB
C#
Executable File
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Opsoft.NetCore.O3App.Domain;
|
|
using Opsoft.NetCore.O3App.Domain.Interface;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.BaseData.IRepositories;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.Equipment.IRepositories;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.Equipment.IServices;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.Equipment.Model;
|
|
using Opsoft.NetCore.O3App.Shared;
|
|
|
|
namespace Opsoft.NetCore.O3App.Services.Equipment
|
|
{
|
|
/// <summary>
|
|
/// 设备管理系统——备件
|
|
/// </summary>
|
|
[MapTo(typeof(ISpareParService), ServiceLifetime.Transient)]
|
|
public class SparePartService : ServiceBase<BaseEntity, ISpareParRepository>, ISpareParService
|
|
{
|
|
readonly ISysConfigDataRepository _sysConfigDataRepository;
|
|
public SparePartService(ISpareParRepository repository, ISysConfigDataRepository sysConfigDataRepository) : base(repository)
|
|
{
|
|
_sysConfigDataRepository = sysConfigDataRepository;
|
|
Init(repository);
|
|
Init(sysConfigDataRepository);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取备件列表
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<GetSparePart>> GetSparePart(dynamic data)
|
|
{
|
|
return await (repository as ISpareParRepository).GetSparePart(data);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 备件入库提交
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public async Task<string> SparePartStorage(SparePartStorage SData)
|
|
{
|
|
if (SData.data == null)
|
|
{
|
|
throw new O3AppException("传参信息错误,未定义", 400);
|
|
}
|
|
if (SData.SData.Count == 0)
|
|
{
|
|
throw new O3AppException("传输参数错误,提交项目未定义", 400);
|
|
}
|
|
if (string.IsNullOrEmpty(SData.basicType))
|
|
{
|
|
throw new O3AppException("类别信息错误,值设定有误", 400);
|
|
}
|
|
return await (repository as ISpareParRepository).SparePartStorage(SData);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 备件盘点提交
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
public async Task<string> SparePartInventory(SparePartStorage SData)
|
|
{
|
|
this.UpdataLoginInfo(repository, await _sysConfigDataRepository.QueryLoginUserInfo(LoginInfo.UserID));
|
|
if (SData.data == null)
|
|
{
|
|
throw new O3AppException("传参信息错误,未定义", 400);
|
|
}
|
|
if (SData.SData == null || SData.SData.Count <= 0)
|
|
{
|
|
throw new O3AppException("录入信息为空", 400);
|
|
}
|
|
return await (repository as ISpareParRepository).SparePartInventory(SData);
|
|
}
|
|
}
|
|
}
|