134 lines
4.2 KiB
C#
134 lines
4.2 KiB
C#
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Microsoft.Extensions.Logging;
|
|||
|
using Syc.Basic.Web.WMS.Dto;
|
|||
|
using Syc.Basic.Web.WMS.Entitys;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Volo.Abp.Domain.Repositories;
|
|||
|
|
|||
|
namespace Syc.Basic.Web.WMS.Service
|
|||
|
{
|
|||
|
public class ProduceService:ApiService
|
|||
|
{
|
|||
|
private readonly IRepository<Produce> produceRepository;
|
|||
|
private readonly ILogger<ProduceService> logger;
|
|||
|
|
|||
|
public ProduceService(IRepository<Produce> produceRepository, ILogger<ProduceService> logger)
|
|||
|
{
|
|||
|
this.produceRepository = produceRepository;
|
|||
|
this.logger = logger;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 查询丝锭
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public async Task<PageOutput<ProduceDto>> GetProduceList(ProduceDto input)
|
|||
|
{
|
|||
|
var list = await produceRepository.GetQueryableAsync();
|
|||
|
list = list.Where(x => x.IsDelete == 0);
|
|||
|
|
|||
|
var data = list.Select(x => new ProduceDto()
|
|||
|
{
|
|||
|
Spec = x.Spec,
|
|||
|
Lot_No = x.Lot_No,
|
|||
|
Id = x.Id,
|
|||
|
Length = x.Length,
|
|||
|
Type = x.Type,
|
|||
|
Exp_Time = x.Exp_Time,
|
|||
|
IfUse = x.IfUse,
|
|||
|
Name = x.Name,
|
|||
|
Qty = x.Qty
|
|||
|
});
|
|||
|
|
|||
|
PageOutput<ProduceDto> pageOutput = new PageOutput<ProduceDto>();
|
|||
|
pageOutput.Total = list.Count();
|
|||
|
pageOutput.Data = data;
|
|||
|
return pageOutput;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 添加丝锭
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public async Task InsertProduce(ProduceDto input)
|
|||
|
{
|
|||
|
foreach (var item in await produceRepository.GetListAsync())
|
|||
|
{
|
|||
|
item.IfUse = 0;
|
|||
|
}
|
|||
|
|
|||
|
var produce = new Produce()
|
|||
|
{
|
|||
|
Length = input.Length,
|
|||
|
Lot_No = input.Lot_No,
|
|||
|
Spec = input.Spec,
|
|||
|
Type = input.Type,
|
|||
|
Qty=input.Qty,
|
|||
|
Exp_Time = input.Exp_Time,
|
|||
|
IfUse = 1,
|
|||
|
Name = input.Name,
|
|||
|
IsDelete = 0
|
|||
|
};
|
|||
|
|
|||
|
await produceRepository.InsertAsync(produce);
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 修改丝锭
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public async Task UpdateProduce(ProduceDto input)
|
|||
|
{
|
|||
|
var produce = await produceRepository.FirstOrDefaultAsync(x => x.Id == input.Id);
|
|||
|
|
|||
|
produce.Spec = input.Spec;
|
|||
|
produce.Type = input.Type;
|
|||
|
produce.Length = input.Length;
|
|||
|
produce.Lot_No = input.Lot_No;
|
|||
|
produce.Qty = input.Qty;
|
|||
|
produce.Exp_Time = input.Exp_Time;
|
|||
|
produce.IfUse = input.IfUse;
|
|||
|
await produceRepository.UpdateAsync(produce);
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 删除丝锭
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public async Task DeleteProduce(ProduceInput input)
|
|||
|
{
|
|||
|
var produce = await produceRepository.FirstOrDefaultAsync(x => x.Id == input.id);
|
|||
|
if (produce == null)
|
|||
|
throw Oops.Oh("删除失败,数据为空");
|
|||
|
produce.IsDelete = 1;
|
|||
|
await produceRepository.UpdateAsync(produce);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 批量删除丝锭
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
[HttpPost]
|
|||
|
public async Task DeletesProduces(ProduceInput input)
|
|||
|
{
|
|||
|
var produces = await produceRepository.GetListAsync(x => input.ids.Contains(x.Id));
|
|||
|
if (produces.Count==0)
|
|||
|
throw Oops.Oh("删除失败,数据为空");
|
|||
|
foreach (var produce in produces)
|
|||
|
{
|
|||
|
produce.IsDelete = 1;
|
|||
|
}
|
|||
|
await produceRepository.UpdateManyAsync(produces);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|