From 1780e84ee463ed0369fc8b346c1b40df5bf86a8a Mon Sep 17 00:00:00 2001 From: tongfei <244188119@qq.com> Date: Sat, 27 Jan 2024 16:57:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=B1=E5=94=9B=E6=8E=A5=E5=8F=A3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/BoxMarkController.cs | 89 +++++++ src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml | 26 +++ src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml | 187 ++++++++++++++- src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml | 159 +++++++++++++ .../Dto/BoxMark/BoxMarkQueryRequest.cs | 46 ++++ .../Dto/BoxMark/BoxMarkQueryResponse.cs | 91 ++++++++ .../Dto/BoxMark/GenerateBoxMarkDto.cs | 67 ++++++ src/WMS.Web.Domain/Entitys/BoxMark.cs | 135 +++++++++++ .../IService/IBoxMarkService.cs | 24 ++ .../Infrastructure/IBoxMarkRepositories.cs | 45 ++++ src/WMS.Web.Domain/Mappers/BoxMarkMapper.cs | 17 ++ src/WMS.Web.Domain/Services/BoxMarkService.cs | 62 +++++ .../BoxMarkRepositories.cs | 217 ++++++++++++++++++ .../Configuration/RepositoryDbContext.cs | 8 +- .../DependencyInjection/AppBuilder.cs | 1 + .../AppBuilderExtensions.cs | 3 +- 16 files changed, 1174 insertions(+), 3 deletions(-) create mode 100644 src/WMS.Web.Api/Controllers/BoxMarkController.cs create mode 100644 src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryRequest.cs create mode 100644 src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryResponse.cs create mode 100644 src/WMS.Web.Core/Dto/BoxMark/GenerateBoxMarkDto.cs create mode 100644 src/WMS.Web.Domain/Entitys/BoxMark.cs create mode 100644 src/WMS.Web.Domain/IService/IBoxMarkService.cs create mode 100644 src/WMS.Web.Domain/Infrastructure/IBoxMarkRepositories.cs create mode 100644 src/WMS.Web.Domain/Mappers/BoxMarkMapper.cs create mode 100644 src/WMS.Web.Domain/Services/BoxMarkService.cs create mode 100644 src/WMS.Web.Repositories/BoxMarkRepositories.cs diff --git a/src/WMS.Web.Api/Controllers/BoxMarkController.cs b/src/WMS.Web.Api/Controllers/BoxMarkController.cs new file mode 100644 index 00000000..54969e70 --- /dev/null +++ b/src/WMS.Web.Api/Controllers/BoxMarkController.cs @@ -0,0 +1,89 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WMS.Web.Core.Dto; +using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Infrastructure; +using WMS.Web.Domain.IService; +using WMS.Web.Domain.IService.Public; +using WMS.Web.Domain.Values; + +namespace WMS.Web.Api.Controllers +{ + /// + /// 箱唛-接口 + /// + [Route("api/[controller]")] + [ApiController] + public class BoxMarkController : ControllerBase + { + + private readonly ILoginService _loginService; + private readonly IBoxMarkService _boxMarkService; + private readonly IBoxMarkRepositories _boxMarkRepositories; + private readonly IExportExcelService _exportExcelService; + public BoxMarkController( + ILoginService loginService, + IBoxMarkRepositories boxMarkRepositories, + IBoxMarkService boxMarkService, + IExportExcelService exportExcelService) + { + this._loginService = loginService; + this._boxMarkService = boxMarkService; + this._exportExcelService = exportExcelService; + this._boxMarkRepositories = boxMarkRepositories; + } + + /// + /// 列表 + /// + /// + /// + [HttpPost] + [Route("GetList")] + public async Task> GetPagedList([FromBody] BoxMarkQueryRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + var (list, count) = await _boxMarkRepositories.GetPagedList(dto, loginInfo.UserInfo.CompanyId); + return ResultPagedList.ReSuccess(list, count); + } + + /// + /// 生成 + /// + /// + /// + [HttpPost] + [Route("generate")] + public async Task DeleteAsync([FromBody] GenerateBoxMarkDto dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + return await _boxMarkService.Generate(dto, loginInfo); + } + + /// + /// 批量删除 + /// + /// + /// + [HttpPost] + [Route("delete")] + public async Task Delete([FromBody] OperateRequest dto) + { + var loginInfo = _loginService.GetLoginInfo(this.HttpContext.Request.Headers["Authorization"]); + if (loginInfo == null || loginInfo.UserInfo == null) + return ResultPagedList.ReFailure(ResultCodes.Token_Invalid_Error); + var isSuccess= await _boxMarkRepositories.DeleteRange(dto.Ids); + if(!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + return Result.ReSuccess(); + } + } +} diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml index 55befc43..5a99af45 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Api.xml @@ -37,6 +37,32 @@ + + + 箱唛-接口 + + + + + 列表 + + + + + + + 生成 + + + + + + + 批量删除 + + + + 改箱 diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml index cb7768ed..457dddb1 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Core.xml @@ -305,6 +305,191 @@ 序列号集 + + + 请求对象 + + + + + 订单编号集合字符串 + + + + + 物料三件套搜索 + + + + + 开始的箱唛编号 + + + + + 结束的箱唛编号 + + + + + 操作人 + + + + + 生成开始时间 + + + + + 生成结束时间 + + + + + 列表响应对象 + + + + + 唯一ID + + + + + 箱唛编号 + + + + + 订单编号 + + + + + 物料规格型号 + + + + + 物料编码 + + + + + 物料名称 + + + + + 69条码 + + + + + 装箱数量 + + + + + 装箱净重 + + + + + 装箱毛重 + + + + + 尾箱数量 + + + + + 尾箱净重 + + + + + 尾箱毛重 + + + + + 备注 + + + + + 操作人 + + + + + 创建时间(生成时间) + + + + + 生成箱唛dto + + + + + 箱唛编号 + + + + + 订单编号 + + + + + 物料ID + + + + + 产品数量 + + + + + 装箱数量 + + + + + 装箱净重 + + + + + 装箱毛重 + + + + + 尾箱数量 + + + + + 尾箱净重 + + + + + 尾箱毛重 + + + + + 备注 + + 箱信息(头部) @@ -4284,7 +4469,7 @@ - 出库结束时间 + 出库完成时间 diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 99fe97c5..a0a1afc6 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -270,6 +270,104 @@ 序列号 + + + 箱唛表 + + + + + ID + + + + + 箱唛编号 + + + + + 箱唛编号-首位 + + + + + 箱唛编号-末尾序号 + + + + + 订单编号 + + + + + 物料ID + + + + + 产品数量 + + + + + 装箱数量 + + + + + 装箱净重 + + + + + 装箱毛重 + + + + + 尾箱数量 + + + + + 尾箱净重 + + + + + 尾箱毛重 + + + + + 备注 + + + + + 操作人 + + + + + 创建时间(生成时间) + + + + + 创建 + + + + + + 生成编号 + + + + wms改箱记录 @@ -2110,6 +2208,41 @@ + + + 箱唛-仓储接口 + + + + + 列表分页 + + + + + + + + 添加 + + + + + + + + 详情-根据最新的ID + + + + + + 批量删除 + + + + + 老ops箱信息 @@ -2611,6 +2744,19 @@ + + + 箱唛-服务接口 + + + + + 生成 + + + + + 改箱 移箱服务 @@ -3890,6 +4036,19 @@ + + + 箱唛-服务 + + + + + 生成 + + + + + 箱服务信息 diff --git a/src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryRequest.cs b/src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryRequest.cs new file mode 100644 index 00000000..4774e8a1 --- /dev/null +++ b/src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryRequest.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto +{ + /// + /// 请求对象 + /// + public class BoxMarkQueryRequest : PaginationBaseRequestDto + { + /// + /// 订单编号集合字符串 + /// + public string OrderBillNos { get; set; } + + /// + /// 物料三件套搜索 + /// + public string Material { get; set; } + + /// + /// 开始的箱唛编号 + /// + public string BeginBillNo { get; set; } + + /// + /// 结束的箱唛编号 + /// + public string EndBillNo { get; set; } + + /// + /// 操作人 + /// + public string Creator { get; set; } + + /// + /// 生成开始时间 + /// + public DateTime? BeginTime { get; set; } = null; + /// + /// 生成结束时间 + /// + public DateTime? EndTime { get; set; } = null; + } +} diff --git a/src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryResponse.cs b/src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryResponse.cs new file mode 100644 index 00000000..53522453 --- /dev/null +++ b/src/WMS.Web.Core/Dto/BoxMark/BoxMarkQueryResponse.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto +{ + /// + /// 列表响应对象 + /// + public class BoxMarkQueryResponse + { + /// + /// 唯一ID + /// + public int Id { get; set; } + + /// + /// 箱唛编号 + /// + public string BillNo { get; set; } + + /// + /// 订单编号 + /// + public string OrderBillNo { get; set; } + + /// + /// 物料规格型号 + /// + public string Specifications { get; set; } + /// + /// 物料编码 + /// + public string MaterialNumber { get; set; } + + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + + /// + /// 69条码 + /// + public string BarCode { get; set; } + + /// + /// 装箱数量 + /// + public decimal CratingQty { get; set; } + + /// + /// 装箱净重 + /// + public decimal CratingNetWeightQty { get; set; } + + /// + /// 装箱毛重 + /// + public decimal CratingGrossWeightQty { get; set; } + + /// + /// 尾箱数量 + /// + public decimal TailboxQty { get; set; } + + /// + /// 尾箱净重 + /// + public decimal TailboxNetWeightQty { get; set; } + + /// + /// 尾箱毛重 + /// + public decimal TailboxGrossWeightQty { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 操作人 + /// + public string Creator { get; set; } + + /// + /// 创建时间(生成时间) + /// + public string CreateTime { get; set; } + } +} diff --git a/src/WMS.Web.Core/Dto/BoxMark/GenerateBoxMarkDto.cs b/src/WMS.Web.Core/Dto/BoxMark/GenerateBoxMarkDto.cs new file mode 100644 index 00000000..6e58724a --- /dev/null +++ b/src/WMS.Web.Core/Dto/BoxMark/GenerateBoxMarkDto.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace WMS.Web.Core.Dto +{ + /// + /// 生成箱唛dto + /// + public class GenerateBoxMarkDto + { + /// + /// 箱唛编号 + /// + public string BillNo { get; set; } + + /// + /// 订单编号 + /// + public string OrderBillNo { get; set; } + + /// + /// 物料ID + /// + public int MaterialId { get; set; } + + /// + /// 产品数量 + /// + public decimal ProductQty { get; set; } + + /// + /// 装箱数量 + /// + public decimal CratingQty { get; set; } + + /// + /// 装箱净重 + /// + public decimal CratingNetWeightQty { get; set; } + + /// + /// 装箱毛重 + /// + public decimal CratingGrossWeightQty { get; set; } + + /// + /// 尾箱数量 + /// + public decimal TailboxQty { get; set; } + + /// + /// 尾箱净重 + /// + public decimal TailboxNetWeightQty { get; set; } + + /// + /// 尾箱毛重 + /// + public decimal TailboxGrossWeightQty { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + } +} diff --git a/src/WMS.Web.Domain/Entitys/BoxMark.cs b/src/WMS.Web.Domain/Entitys/BoxMark.cs new file mode 100644 index 00000000..46e5f054 --- /dev/null +++ b/src/WMS.Web.Domain/Entitys/BoxMark.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using WMS.Web.Core; + +namespace WMS.Web.Domain.Entitys +{ + /// + /// 箱唛表 + /// + [Serializable] + [Table("t_wms_box_mark")] + public class BoxMark : EntityBase + { + /// + /// ID + /// + public override int Id { get; set; } + + /// + /// 箱唛编号 + /// + public string BillNo { get; set; } + + /// + /// 箱唛编号-首位 + /// + public int FirstBillNo { get; set; } + + /// + /// 箱唛编号-末尾序号 + /// + public int LastBillNo { get; set; } + + /// + /// 订单编号 + /// + public string OrderBillNo { get; set; } + + /// + /// 物料ID + /// + public int MaterialId { get; set; } + + /// + /// 产品数量 + /// + public decimal ProductQty { get; set; } + + /// + /// 装箱数量 + /// + public decimal CratingQty { get; set; } + + /// + /// 装箱净重 + /// + public decimal CratingNetWeightQty { get; set; } + + /// + /// 装箱毛重 + /// + public decimal CratingGrossWeightQty { get; set; } + + /// + /// 尾箱数量 + /// + public decimal TailboxQty { get; set; } + + /// + /// 尾箱净重 + /// + public decimal TailboxNetWeightQty { get; set; } + + /// + /// 尾箱毛重 + /// + public decimal TailboxGrossWeightQty { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 操作人 + /// + public int CreatorId { get; set; } + + /// + /// 创建时间(生成时间) + /// + public DateTime CreateTime { get; set; } + + /// + /// 创建 + /// + /// + public void Create(int creatorId) + { + this.CreatorId = creatorId; + this.CreateTime = DateTime.Now; + } + + /// + /// 生成编号 + /// + /// + /// + public void GenerateBillNo(int firstBillNo,int lastBillNo) + { + this.FirstBillNo=Convert.ToInt32(DateTime.Now.ToString("yyMMdd")); + if (this.FirstBillNo == firstBillNo) + this.LastBillNo = lastBillNo + 1; + else + this.LastBillNo = 1; + + if (this.LastBillNo.ToString().Length >= 5) + { + this.BillNo = "XM" + this.FirstBillNo + this.LastBillNo; + return; + } + + string lastStr = this.LastBillNo.ToString(); + while (true) + { + lastStr = "0" + lastStr; + if (lastStr.Length >= 5) break; + } + this.BillNo = "XM" + this.FirstBillNo + lastStr; + } + + } +} diff --git a/src/WMS.Web.Domain/IService/IBoxMarkService.cs b/src/WMS.Web.Domain/IService/IBoxMarkService.cs new file mode 100644 index 00000000..6c4dd3e7 --- /dev/null +++ b/src/WMS.Web.Domain/IService/IBoxMarkService.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto; +using WMS.Web.Core.Dto.Login; +using WMS.Web.Core.Internal.Results; + +namespace WMS.Web.Domain.IService +{ + /// + /// 箱唛-服务接口 + /// + public interface IBoxMarkService + { + /// + /// 生成 + /// + /// + /// + /// + Task Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo); + } +} diff --git a/src/WMS.Web.Domain/Infrastructure/IBoxMarkRepositories.cs b/src/WMS.Web.Domain/Infrastructure/IBoxMarkRepositories.cs new file mode 100644 index 00000000..47249f4a --- /dev/null +++ b/src/WMS.Web.Domain/Infrastructure/IBoxMarkRepositories.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto; +using WMS.Web.Domain.Entitys; + +namespace WMS.Web.Domain.Infrastructure +{ + /// + /// 箱唛-仓储接口 + /// + public interface IBoxMarkRepositories + { + /// + /// 列表分页 + /// + /// + /// + /// + Task<(List list, int total)> GetPagedList(BoxMarkQueryRequest dto, int companyId); + + /// + /// 添加 + /// + /// + /// + /// + Task Add(BoxMark entity, bool isTransaction = true); + + /// + /// 详情-根据最新的ID + /// + /// + Task GetBy(); + + /// + /// 批量删除 + /// + /// + /// + /// + Task DeleteRange(List ids, bool isTransaction = true); + } +} diff --git a/src/WMS.Web.Domain/Mappers/BoxMarkMapper.cs b/src/WMS.Web.Domain/Mappers/BoxMarkMapper.cs new file mode 100644 index 00000000..6b8598b7 --- /dev/null +++ b/src/WMS.Web.Domain/Mappers/BoxMarkMapper.cs @@ -0,0 +1,17 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Text; +using WMS.Web.Core.Dto; +using WMS.Web.Domain.Entitys; + +namespace WMS.Web.Domain.Mappers +{ + public class BoxMarkMapper : Profile + { + public BoxMarkMapper() + { + CreateMap(); + } + } +} diff --git a/src/WMS.Web.Domain/Services/BoxMarkService.cs b/src/WMS.Web.Domain/Services/BoxMarkService.cs new file mode 100644 index 00000000..091cec42 --- /dev/null +++ b/src/WMS.Web.Domain/Services/BoxMarkService.cs @@ -0,0 +1,62 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto; +using WMS.Web.Core.Dto.Login; +using WMS.Web.Core.Internal.Results; +using WMS.Web.Domain.Entitys; +using WMS.Web.Domain.Infrastructure; +using WMS.Web.Domain.IService; +using WMS.Web.Domain.IService.Public; +using WMS.Web.Domain.Values; + +namespace WMS.Web.Domain.Services +{ + /// + /// 箱唛-服务 + /// + public class BoxMarkService : IBoxMarkService + { + private readonly IMapper _mapper; + public readonly IBasicsRepositories _transactionRepositories; + private readonly IBoxMarkRepositories _boxMarkRepositories; + public BoxMarkService(IMapper mapper, + IBasicsRepositories transactionRepositories, + IBoxMarkRepositories boxMarkRepositories) + { + _mapper = mapper; + _transactionRepositories = transactionRepositories; + _boxMarkRepositories = boxMarkRepositories; + } + + /// + /// 生成 + /// + /// + /// + /// + public async Task Generate(GenerateBoxMarkDto dto, LoginInDto loginInfo) + { + //1.获取最新的箱唛信息 + var entity_new = await _boxMarkRepositories.GetBy(); + + //2.dto映射实体 + var entity = new BoxMark(); + entity= _mapper.Map(dto, entity); + entity.Create(loginInfo.UserInfo.StaffId); + + var new_firstBillNo = entity_new == null ? 0 : entity_new.FirstBillNo; + var new_lastBillNo = entity_new == null ? 0 : entity_new.LastBillNo; + entity.GenerateBillNo(new_firstBillNo, new_lastBillNo); + + //添加 + var isSuccess = await _boxMarkRepositories.Add(entity); + if (!isSuccess) + return Result.ReFailure(ResultCodes.DateWriteError); + + return Result.ReSuccess(); + } + } +} diff --git a/src/WMS.Web.Repositories/BoxMarkRepositories.cs b/src/WMS.Web.Repositories/BoxMarkRepositories.cs new file mode 100644 index 00000000..f8f1b328 --- /dev/null +++ b/src/WMS.Web.Repositories/BoxMarkRepositories.cs @@ -0,0 +1,217 @@ +using AutoMapper; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WMS.Web.Core.Dto; +using WMS.Web.Core.Dto.Erp; +using WMS.Web.Domain.Entitys; +using WMS.Web.Domain.Infrastructure; +using WMS.Web.Domain.IService.Public; +using WMS.Web.Domain.Values.Single; +using WMS.Web.Repositories.Configuration; + +namespace WMS.Web.Repositories +{ + /// + /// 箱唛-仓储 + /// + public class BoxMarkRepositories : IBoxMarkRepositories + { + private readonly ILoginRepositories _loginRepositories; + private readonly RepositoryDbContext _context; + private readonly ISingleDataService _singleDataService; + private readonly IErpService _erpService; + private readonly IErpBasicDataExtendService _erpBasicDataExtendService; + private readonly IBasicsRepositories _basicsRepositories; + + + public BoxMarkRepositories(RepositoryDbContext context, + IErpService erpService, + ILoginRepositories loginRepositories, + ISingleDataService singleDataService, + IBasicsRepositories basicsRepositories, + IErpBasicDataExtendService erpBasicDataExtendService) + { + _context = context; + _erpService = erpService; + _basicsRepositories = basicsRepositories; + _loginRepositories = loginRepositories; + _singleDataService = singleDataService; + _erpBasicDataExtendService = erpBasicDataExtendService; + } + + /// + /// 列表-分页 + /// + /// + /// + public async Task<(List list, int total)> GetPagedList(BoxMarkQueryRequest dto, int companyId) + { + //1.获取物料集合和组织集合和供应商的集合 + var materials = new List(); + var materials_result = await _erpService.BillQueryForMaterial(); + if (materials_result.IsSuccess) + materials = materials_result.Data.ToList(); + + + //物料集合;模糊查询后的物料集合 + if (!string.IsNullOrEmpty(dto.Material)) + materials = materials.Where(w => w.MaterialNumber.Contains(dto.Material) || w.MaterialName.Contains(dto.Material) || w.Specifications.Contains(dto.Material)).ToList(); + + if (companyId == 0) + companyId = _loginRepositories.CompanyId; + List cr_ids = new List(); + if (!string.IsNullOrEmpty(dto.Creator)) + { + var staffList = await _basicsRepositories.GetStaffListAsync(companyId); + if (staffList != null) + cr_ids = staffList.Where(w => w.Name.Contains(dto.Creator)).Select(s => s.Id).ToList(); + } + var query = _context.BoxMark.Where(adv => 1 == 1); + + //编号查询 + if (!string.IsNullOrEmpty(dto.BeginBillNo) && + !string.IsNullOrEmpty(dto.EndBillNo)) + { + if (dto.BeginBillNo.ToString().Length >= 13 && dto.EndBillNo.ToString().Length >= 13) + { + var begYMD = Convert.ToInt32(dto.BeginBillNo.Substring(2, 6)); + var endYMD = Convert.ToInt32(dto.EndBillNo.Substring(2, 6)); + //if (begYMD <= endYMD) + + var begNo = Convert.ToInt32(dto.BeginBillNo.Substring(8)); + var endNo = Convert.ToInt32(dto.EndBillNo.Substring(8)); + query = query.Where(w => w.FirstBillNo >= begYMD && w.FirstBillNo <= endYMD && w.LastBillNo >= begNo && w.LastBillNo <= endNo); + } + } + else + query = query.Where(w => w.BillNo == dto.BeginBillNo || w.BillNo == dto.EndBillNo); + + //订单号查询 + if (!string.IsNullOrEmpty(dto.OrderBillNos)) + { + var orderBNS = dto.OrderBillNos.Replace(",", ","); + var orderBillNoList= orderBNS.Split(",").Where(x => !string.IsNullOrEmpty(x)).ToList(); + if (orderBillNoList != null && orderBillNoList.Count != 0) + { + query = query.Where(w => orderBillNoList.Contains(w.OrderBillNo)); + } + } + + //物料ID在模糊后的物料 + if (!string.IsNullOrEmpty(dto.Material)) + { + if (materials != null && materials.Count != 0) + { + var mids = materials.Select(x => x.MaterialId).ToList(); + query = query.Where(w => mids.Contains(w.MaterialId)); + } + } + + if (cr_ids.Count != 0) + query = query.Where(w => cr_ids.Contains(w.CreatorId)); + + if (dto.BeginTime != null) + query = query.Where(w => w.CreateTime >= dto.BeginTime.Value); + if (dto.EndTime != null) + query = query.Where(w => w.CreateTime <= dto.EndTime.Value); + + int total = await query.CountAsync(); + var list = await query.Select(s => new BoxMarkQueryResponse() + { + Id = s.Id, + BillNo = s.BillNo, + OrderBillNo = s.OrderBillNo, + MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.MaterialId), + MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.MaterialId), + Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.MaterialId), + BarCode = "", + + CratingQty = s.CratingQty, + CratingNetWeightQty = s.CratingNetWeightQty, + CratingGrossWeightQty = s.CratingGrossWeightQty, + + TailboxQty = s.TailboxQty, + TailboxNetWeightQty = s.TailboxNetWeightQty, + TailboxGrossWeightQty = s.TailboxGrossWeightQty, + + Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.CreatorId), + CreateTime = s.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), + Remark = s.Remark + }).OrderByDescending(x => x.Id).Skip((dto.PageNo - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync(); + + return (list, total); + } + + /// + /// 新增 + /// + /// + /// + /// + public async Task Add(BoxMark entity, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + await _context.BoxMark.AddAsync(entity); + await _context.SaveChangesAsync(); + if (_transaction != null) + _transaction.Commit(); + return true; + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + + } + + /// + /// 详情-根据最新的ID + /// + /// + /// + public async Task GetBy() + { + var entity = await _context.BoxMark.OrderByDescending(x => x.Id).FirstOrDefaultAsync(); + return entity; + } + + /// + /// 批量删除 + /// + /// + /// + public async Task DeleteRange(List ids, bool isTransaction = true) + { + IDbContextTransaction _transaction = null; + if (isTransaction) + _transaction = _context.Database.BeginTransaction(); + try + { + var list = await _context.BoxMark.Where(f => ids.Contains(f.Id)).ToListAsync(); + _context.BoxMark.RemoveRange(list); + await _context.SaveChangesAsync(); + + if (_transaction != null) + _transaction.Commit(); + } + catch (Exception ex) + { + if (_transaction != null) + _transaction.Rollback(); + return false; + } + return true; + } + } +} diff --git a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs index 97abbe82..06ae4eb4 100644 --- a/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs +++ b/src/WMS.Web.Repositories/Configuration/RepositoryDbContext.cs @@ -351,11 +351,17 @@ namespace WMS.Web.Repositories.Configuration }); #endregion + //箱唛表 + builder.Entity(ent => + { + ent.ToTable("t_wms_box_mark"); + ent.HasKey(x => x.Id); + }); base.OnModelCreating(builder); } - + public DbSet BoxMark { get; set; } public DbSet FileDownManager { get; set; } public DbSet SerialNumbers { get; set; } public DbSet ErpOpsSyncDate { get; set; } diff --git a/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs b/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs index 6b7efb83..b2889efd 100644 --- a/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs +++ b/src/WMS.Web.Repositories/DependencyInjection/AppBuilder.cs @@ -294,6 +294,7 @@ namespace WMS.Web.Repositories.DependencyInjection Services.AddTransient(); Services.AddTransient(); Services.AddTransient(); + Services.AddTransient(); } } diff --git a/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs b/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs index ffddeee7..befee5a7 100644 --- a/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs +++ b/src/WMS.Web.Repositories/DependencyInjection/AppBuilderExtensions.cs @@ -77,7 +77,8 @@ namespace Microsoft.Extensions.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); - + services.AddTransient(); + } } }