using Admin.NET.Core.Service; using Admin.NET.Application.Entity; using Microsoft.AspNetCore.Http; using System.Data; using System.Web; using System.Text; using DocumentFormat.OpenXml.Office.CustomUI; using Microsoft.CodeAnalysis.Operations; namespace Admin.NET.Application; /// /// 操作任务服务 /// [ApiDescriptionSettings(ApplicationConst.WmsTaskGroupName, Order = 100)] public class WmsOperationTaskService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; private readonly SqlSugarRepository _wmsStockQuanRep; private readonly SqlSugarRepository _mesPackageGatherRep; private readonly SqlSugarRepository _sysConfigRep; public WmsOperationTaskService(SqlSugarRepository rep, SqlSugarRepository wmsStockQuanRep , SqlSugarRepository mesPackageGatherRep , SqlSugarRepository sysConfigRep ) { _sysConfigRep = sysConfigRep; _mesPackageGatherRep = mesPackageGatherRep; _rep = rep; _wmsStockQuanRep = wmsStockQuanRep; } /// /// 强制出库 /// /// /// [HttpPost] [ApiDescriptionSettings(Name = "ForceOutbound")] [Description("WmsOperationTask/ForceOutbound")] public async Task ForceOutbound(ForceOutboundInput input) { if (input == null || input.PackageCodeList?.Count == 0) { throw Oops.Oh("参数不能为空"); } List updateQuanList = new List(); foreach (var item in input.PackageCodeList) { var quanList = await _wmsStockQuanRep.AsQueryable().Where(x => x.PackageCode == item).ToListAsync(); var isExist = quanList.Where(x => x.StockStatus == StockStatusEnum.齐包待出库).Count(); if (isExist > 0) { throw Oops.Oh($"包{item}中其中有板状态是'{StockStatusEnum.齐包待出库.ToString()}',不允许强制出库"); } //更新状态 foreach (var quan in quanList) { quan.StockStatus = StockStatusEnum.人工强制待出库; quan.UpdateTime = DateTime.Now; quan.OperReason = "人工强制待出库"; } updateQuanList.AddRange(quanList); } await _wmsStockQuanRep.UpdateRangeAsync(updateQuanList); } /// /// 判断齐套 /// /// /// [HttpPost] [ApiDescriptionSettings(Name = "ValdateQiTao")] [Description("WmsOperationTask/ValdateQiTao")] public async Task ValdateQiTao(ValidateQiTaoInput input) { ValidateQiTaoOutput output = new ValidateQiTaoOutput(); if (input == null || input.PackageCode == null) { throw Oops.Oh("参数不能为空"); } var singlePackage = await _mesPackageGatherRep.AsQueryable().Where(x => x.PackageCode == input.PackageCode).FirstAsync(); if (singlePackage == null) { throw Oops.Oh($"没有找到包号{input.PackageCode}的汇总数据"); } var setValue = ""; var _QiTaoReuslt = ""; var other_orderList = await _mesPackageGatherRep.AsQueryable().Where(x => x.Info5 == singlePackage.Info5 && x.PackageCode != input.PackageCode).ToListAsync(); var num = other_orderList.Where(x => x.UpiStatus == UpiStatusEnum.初始 || x.UpiStatus == UpiStatusEnum.不齐包).Count(); if (num > 0) { //不齐套 setValue = $"{input.PackageCode}|不齐套"; _QiTaoReuslt = "不齐套"; } else { setValue = $"{input.PackageCode}|齐套"; _QiTaoReuslt = "齐套"; } var sysConfig = await _sysConfigRep.GetFirstAsync(x => x.Code == CommonConst.WmsBZ30_QiTao); if (sysConfig == null) { throw Oops.Oh($"没有配置 判断齐套 值"); } if (!string.IsNullOrEmpty(sysConfig.Value)) { throw Oops.Oh($"判断齐套值已经存在值{sysConfig.Value},不允许操作"); } sysConfig.Value = setValue; await _sysConfigRep.UpdateAsync(sysConfig); output = singlePackage.Adapt(); output.QiTaoReuslt = _QiTaoReuslt; return output; } }