From eee9129baea18bd089b980a6416f8331103ba9c7 Mon Sep 17 00:00:00 2001 From: syc_zhaoqianyan Date: Tue, 24 Jun 2025 18:26:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=94=9F=E4=BA=A7=E7=AE=A1=E7=90=86=E7=9A=84?= =?UTF-8?q?crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/BoxDto.cs | 1 + .../Dto/ProduceDto.cs | 23 +++ .../Dto/ProduceInput.cs | 13 ++ .../Dto/SilkDto.cs | 1 + .../Service/BoxService.cs | 26 ++-- .../Service/ProduceService.cs | 133 ++++++++++++++++++ .../Service/SilkService.cs | 15 +- .../Syc.Basic.Web.WMS.Application.xml | 39 ++++- .../Syc.Basic.Web.WMS.Domain.Shared.csproj | 1 + .../Syc.Basic.Web.WMS.Domain/Entitys/Box.cs | 1 + .../Entitys/Produce.cs | 23 +++ .../Syc.Basic.Web.WMS.Domain/Entitys/Silk.cs | 1 + 12 files changed, 261 insertions(+), 16 deletions(-) create mode 100644 services/Syc.Basic.Web.WMS.Application/Dto/ProduceDto.cs create mode 100644 services/Syc.Basic.Web.WMS.Application/Dto/ProduceInput.cs create mode 100644 services/Syc.Basic.Web.WMS.Application/Service/ProduceService.cs create mode 100644 services/Syc.Basic.Web.WMS.Domain/Entitys/Produce.cs diff --git a/services/Syc.Basic.Web.WMS.Application/Dto/BoxDto.cs b/services/Syc.Basic.Web.WMS.Application/Dto/BoxDto.cs index bcb0a15..bb94eb6 100644 --- a/services/Syc.Basic.Web.WMS.Application/Dto/BoxDto.cs +++ b/services/Syc.Basic.Web.WMS.Application/Dto/BoxDto.cs @@ -18,5 +18,6 @@ namespace Syc.Basic.Web.WMS.Dto public double? Length { get; set; } public DateTime? Dom_Time { get; set; } public DateTime? Exp_Time { get; set; } + public int IsDelete { get; set; } } } diff --git a/services/Syc.Basic.Web.WMS.Application/Dto/ProduceDto.cs b/services/Syc.Basic.Web.WMS.Application/Dto/ProduceDto.cs new file mode 100644 index 0000000..08325e7 --- /dev/null +++ b/services/Syc.Basic.Web.WMS.Application/Dto/ProduceDto.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Mvc.Razor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Syc.Basic.Web.WMS.Dto +{ + public class ProduceDto + { + public int Id { get; set; } + public string Type { get; set; } + public string Spec { get; set; } + public double Length { get; set; } + public string Lot_No { get; set; } + public string Name { get; set; } + public int? Qty { get; set; } + public DateTime? Exp_Time { get; set; } + public int IfUse { get; set; } + public int IsDelete { get; set; } + } +} diff --git a/services/Syc.Basic.Web.WMS.Application/Dto/ProduceInput.cs b/services/Syc.Basic.Web.WMS.Application/Dto/ProduceInput.cs new file mode 100644 index 0000000..5933f97 --- /dev/null +++ b/services/Syc.Basic.Web.WMS.Application/Dto/ProduceInput.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Syc.Basic.Web.WMS.Dto +{ + public class ProduceInput:BoxInput + { + + } +} diff --git a/services/Syc.Basic.Web.WMS.Application/Dto/SilkDto.cs b/services/Syc.Basic.Web.WMS.Application/Dto/SilkDto.cs index 1df4734..cf65638 100644 --- a/services/Syc.Basic.Web.WMS.Application/Dto/SilkDto.cs +++ b/services/Syc.Basic.Web.WMS.Application/Dto/SilkDto.cs @@ -16,5 +16,6 @@ namespace Syc.Basic.Web.WMS.Dto public double? Length { get; set; } public DateTime? Date { get; set; } public string? Lot_No { get; set; } + public int IsDelete { get; set; } } } diff --git a/services/Syc.Basic.Web.WMS.Application/Service/BoxService.cs b/services/Syc.Basic.Web.WMS.Application/Service/BoxService.cs index 99fbbe8..f47f1cf 100644 --- a/services/Syc.Basic.Web.WMS.Application/Service/BoxService.cs +++ b/services/Syc.Basic.Web.WMS.Application/Service/BoxService.cs @@ -33,6 +33,7 @@ namespace Syc.Basic.Web.WMS.Service public async Task> GetBoxList(BoxDto input) { var boxlist = await boxRepository.GetQueryableAsync(); + boxlist = boxlist.Where(x => x.IsDelete == 0); if (input.Name != null) boxlist = boxlist.Where(x => x.Name.Contains(input.Name)); if (input.Spec != null) @@ -75,7 +76,8 @@ namespace Syc.Basic.Web.WMS.Service Lot_No = input.Lot_No, Code = input.Code, Net_Weight = input.Net_Weight, - Spec = input.Spec + Spec = input.Spec, + IsDelete = 0 }; await boxRepository.InsertAsync(box); } @@ -98,7 +100,6 @@ namespace Syc.Basic.Web.WMS.Service box.Qty = input.Qty; box.Name = input.Name; box.Exp_Time = input.Exp_Time; - await boxRepository.UpdateAsync(box); } /// @@ -107,12 +108,13 @@ namespace Syc.Basic.Web.WMS.Service /// /// [HttpPost] - public async Task DeleteSilkList(BoxInput input) + public async Task DeleteBox(BoxInput input) { - var silk = await boxRepository.FirstOrDefaultAsync(x => x.Id == input.id); - if (silk == null) + var box = await boxRepository.FirstOrDefaultAsync(x => x.Id == input.id); + if (box == null) throw Oops.Oh("删除失败,数据为空"); - await boxRepository.DeleteAsync(silk); + box.IsDelete = 1; + await boxRepository.UpdateAsync(box); } /// @@ -121,12 +123,16 @@ namespace Syc.Basic.Web.WMS.Service /// /// [HttpPost] - public async Task DeletesSilkList(BoxInput input) + public async Task DeletesBoxs(BoxInput input) { - var silks = await boxRepository.GetListAsync(x => input.ids.Contains(x.Id)); - if (silks == null) + var boxs = await boxRepository.GetListAsync(x => input.ids.Contains(x.Id)); + if (boxs.Count == 0) throw Oops.Oh("删除失败,数据为空"); - await boxRepository.DeleteManyAsync(silks); + for(var i = 0; i < boxs.Count; i++) + { + boxs[i].IsDelete = 1; + } + await boxRepository.UpdateManyAsync(boxs); } } } diff --git a/services/Syc.Basic.Web.WMS.Application/Service/ProduceService.cs b/services/Syc.Basic.Web.WMS.Application/Service/ProduceService.cs new file mode 100644 index 0000000..1189514 --- /dev/null +++ b/services/Syc.Basic.Web.WMS.Application/Service/ProduceService.cs @@ -0,0 +1,133 @@ +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 produceRepository; + private readonly ILogger logger; + + public ProduceService(IRepository produceRepository, ILogger logger) + { + this.produceRepository = produceRepository; + this.logger = logger; + } + /// + /// 查询丝锭 + /// + /// + /// + [HttpPost] + public async Task> 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 pageOutput = new PageOutput(); + pageOutput.Total = list.Count(); + pageOutput.Data = data; + return pageOutput; + } + /// + /// 添加丝锭 + /// + /// + /// + [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); + } + /// + /// 修改丝锭 + /// + /// + /// + [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); + } + /// + /// 删除丝锭 + /// + /// + /// + [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); + } + + /// + /// 批量删除丝锭 + /// + /// + /// + [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); + } + } +} diff --git a/services/Syc.Basic.Web.WMS.Application/Service/SilkService.cs b/services/Syc.Basic.Web.WMS.Application/Service/SilkService.cs index 83b0d03..0c1bfd7 100644 --- a/services/Syc.Basic.Web.WMS.Application/Service/SilkService.cs +++ b/services/Syc.Basic.Web.WMS.Application/Service/SilkService.cs @@ -33,6 +33,7 @@ namespace Syc.Basic.Web.WMS.Service public async Task> GetSilkList(SilkDto input) { var silklist = await silkRepository.GetQueryableAsync(); + silklist = silklist.Where(x => x.IsDelete == 0); if (input.Type != null) silklist = silklist.Where(x => x.Type.Contains(input.Type)); @@ -69,7 +70,8 @@ namespace Syc.Basic.Web.WMS.Service Code = input.Code, Net_Weight = input.Net_Weight, Spec = input.Spec, - Type = input.Type + Type = input.Type, + IsDelete = 0 }; await silkRepository.InsertAsync(silk); } @@ -103,7 +105,8 @@ namespace Syc.Basic.Web.WMS.Service var silk = await silkRepository.FirstOrDefaultAsync(x => x.Id == input.id); if (silk == null) throw Oops.Oh("删除失败,数据为空"); - await silkRepository.DeleteAsync(silk); + silk.IsDelete = 1; + await silkRepository.UpdateAsync(silk); } /// @@ -115,9 +118,13 @@ namespace Syc.Basic.Web.WMS.Service public async Task DeletesSilks(SilkInput input) { var silks = await silkRepository.GetListAsync(x => input.ids.Contains(x.Id)); - if (silks == null) + if (silks.Count == 0) throw Oops.Oh("删除失败,数据为空"); - await silkRepository.DeleteManyAsync(silks); + foreach (var silk in silks) + { + silk.IsDelete = 1; + } + await silkRepository.UpdateManyAsync(silks); } } } diff --git a/services/Syc.Basic.Web.WMS.Application/Syc.Basic.Web.WMS.Application.xml b/services/Syc.Basic.Web.WMS.Application/Syc.Basic.Web.WMS.Application.xml index 5e54732..4c3a702 100644 --- a/services/Syc.Basic.Web.WMS.Application/Syc.Basic.Web.WMS.Application.xml +++ b/services/Syc.Basic.Web.WMS.Application/Syc.Basic.Web.WMS.Application.xml @@ -57,20 +57,55 @@ - + 删除纸箱 - + 批量删除纸箱 + + + 查询丝锭 + + + + + + + 添加丝锭 + + + + + + + 修改丝锭 + + + + + + + 删除丝锭 + + + + + + + 批量删除丝锭 + + + + 查询丝锭 diff --git a/services/Syc.Basic.Web.WMS.Domain.Shared/Syc.Basic.Web.WMS.Domain.Shared.csproj b/services/Syc.Basic.Web.WMS.Domain.Shared/Syc.Basic.Web.WMS.Domain.Shared.csproj index 826c3de..89b5dc3 100644 --- a/services/Syc.Basic.Web.WMS.Domain.Shared/Syc.Basic.Web.WMS.Domain.Shared.csproj +++ b/services/Syc.Basic.Web.WMS.Domain.Shared/Syc.Basic.Web.WMS.Domain.Shared.csproj @@ -20,6 +20,7 @@ + diff --git a/services/Syc.Basic.Web.WMS.Domain/Entitys/Box.cs b/services/Syc.Basic.Web.WMS.Domain/Entitys/Box.cs index b00deb0..7eb84c4 100644 --- a/services/Syc.Basic.Web.WMS.Domain/Entitys/Box.cs +++ b/services/Syc.Basic.Web.WMS.Domain/Entitys/Box.cs @@ -18,5 +18,6 @@ namespace Syc.Basic.Web.WMS.Entitys public double? Length { get; set; } public DateTime? Dom_Time { get; set; } public DateTime? Exp_Time { get; set; } + public int IsDelete { get; set; } } } diff --git a/services/Syc.Basic.Web.WMS.Domain/Entitys/Produce.cs b/services/Syc.Basic.Web.WMS.Domain/Entitys/Produce.cs new file mode 100644 index 0000000..013e154 --- /dev/null +++ b/services/Syc.Basic.Web.WMS.Domain/Entitys/Produce.cs @@ -0,0 +1,23 @@ +using Nito.AsyncEx; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Domain.Entities; + +namespace Syc.Basic.Web.WMS.Entitys +{ + public class Produce:Entity + { + public string Type { get; set; } + public string Spec { get; set; } + public double Length { get; set; } + public string Lot_No { get; set; } + public string Name { get; set; } + public int? Qty { get; set; } + public DateTime? Exp_Time { get; set; } + public int IfUse { get; set; } + public int IsDelete { get; set; } + } +} diff --git a/services/Syc.Basic.Web.WMS.Domain/Entitys/Silk.cs b/services/Syc.Basic.Web.WMS.Domain/Entitys/Silk.cs index 3ec5a54..7928c3c 100644 --- a/services/Syc.Basic.Web.WMS.Domain/Entitys/Silk.cs +++ b/services/Syc.Basic.Web.WMS.Domain/Entitys/Silk.cs @@ -16,5 +16,6 @@ namespace Syc.Basic.Web.WMS.Entitys public double? Length { get; set; } public DateTime? Date { get; set; } public string? Lot_No { get; set; } + public int IsDelete { get; set; } } }