From 02038504f14d5a0e0f860044a102afe62907d454 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期五, 10 一月 2025 09:52:36 +0800 Subject: [PATCH] 添加获取旧WMS辅料仓库存接口方法及辅料仓功能 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs | 124 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 122 insertions(+), 2 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs" index b7724a4..701cb7b 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs" @@ -1,4 +1,5 @@ 锘縰sing HslCommunication.WebSocket; +using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using SqlSugar; using System; @@ -6,16 +7,22 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using WIDESEA_Common.CommonEnum; using WIDESEA_Common.LocationEnum; +using WIDESEA_Common.StockEnum; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; +using WIDESEA_Core.Const; +using WIDESEA_Core.DB; using WIDESEA_Core.Enums; using WIDESEA_Core.Helper; +using WIDESEA_Core.Seed; using WIDESEA_Core.Utilities; using WIDESEA_DTO.Basic; using WIDESEA_IBasicRepository; using WIDESEA_IBasicService; +using WIDESEA_IStockRepository; using WIDESEA_Model.Models; namespace WIDESEA_BasicService @@ -24,13 +31,14 @@ { private readonly IUnitOfWorkManage _unitOfWorkManage; private readonly IBasicRepository _basicRepository; - + private readonly IStockInfoRepository _stockInfoRepository; public ILocationInfoRepository Repository => BaseDal; - public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository) : base(BaseDal) + public LocationInfoService(ILocationInfoRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository, IStockInfoRepository stockInfoRepository) : base(BaseDal) { _unitOfWorkManage = unitOfWorkManage; _basicRepository = basicRepository; + _stockInfoRepository = stockInfoRepository; } /// <summary> @@ -88,6 +96,118 @@ } /// <summary> + /// 鑾峰彇杈呮枡浠撳簱瀛� + /// </summary> + /// <returns></returns> + public WebResponseContent GetContainerInfo() + { + try + { + SqlSugarClient TesugarClient = new SqlSugarClient(new ConnectionConfig + { + ConfigId = MainDb.CurrentDbConnId, + ConnectionString = AppSettings.Get("TeConnectionString").DecryptDES(AppSecret.DB), + IsAutoCloseConnection = true, + DbType = MainDb.DbType, + }); + + var ContainerInfos = TesugarClient.Queryable("ContainerInfo", "x").Where("WaId", "=", 8).Where("UpState", "=", 2).ToList(); + if (ContainerInfos != null) + { + List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>(); + foreach (var item in ContainerInfos) + { + dynamic ruleConfig = item; + int id = ruleConfig.CId;//涓婚敭 + string BoxNo = ruleConfig.BoxNo;//绠卞彿 + string LNo = ruleConfig.LNo;//璐т綅缂栧彿 + Dt_StockInfo stockInfo = new Dt_StockInfo() + { + LocationCode = LNo == "骞冲簱浣�" ? LNo : GetLocationCode(LNo), + PalletCode = BoxNo, + StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(), + WarehouseId = 5, + PalletType = PalletTypeEnum.LargestPallet.ObjToInt(), + Details = new List<Dt_StockInfoDetail>() + }; + var ContainerDetailsInfos = TesugarClient.Queryable("ContainerDetailsInfo", "x").Where("CId", "=", id).ToList(); + foreach (var ContainerDetailsInfo in ContainerDetailsInfos) + { + dynamic ruleConfig1 = ContainerDetailsInfo; + string MaterialCode = ruleConfig1.MaterialCode;//鐗╂枡缂栧彿 + string MaterialName = ruleConfig1.MaterialName;//鐗╂枡鍚嶇О + string MaterialLot = ruleConfig1.MaterialLot;//鐗╂枡鎵瑰彿 + var PackQty = ruleConfig1.PackQty;//鏁伴噺 + string ProduceData = ruleConfig1.ProduceData;//鐢熸垚鏃ユ湡 + string ValidData = ruleConfig1.ValidData;//鏈夋晥鏈� + string Unit = ruleConfig1.Unit;//鍗曚綅 + string Standard = ruleConfig1.Standard;//澶囨敞 + int MId = ruleConfig1.MId;//鍏ュ簱鍗曟槑缁嗚鍙� + string Model = ruleConfig1.Model;//鍗曟嵁缂栧彿 + Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() + { + MaterielCode = MaterialCode, + MaterielName = MaterialName, + BatchNo = MaterialLot, + OrderNo = Model, + SerialNumber = "", + StockQuantity = (float)PackQty, + OutboundQuantity = 0, + Unit = Unit, + Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(), + ProductionDate = ProduceData, + EffectiveDate = ValidData ?? "1", + Remark = Standard, + InboundOrderRowNo = MId, + }; + stockInfo.Details.Add(stockInfoDetail); + } + stockInfos.Add(stockInfo); + } + var LocationCodes = stockInfos/*.Where(x => x.LocationCode != "骞冲簱浣�")*/.Select(stockInfo => stockInfo.LocationCode).ToList(); + List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => LocationCodes.Contains(x.LocationCode)); + locationInfos.ForEach(x => + { + x.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + x.EnableStatus = EnableStatusEnum.Normal.ObjToInt(); + }); + _unitOfWorkManage.BeginTran(); + _stockInfoRepository.Db.InsertNav(stockInfos).Include(x => x.Details).ExecuteCommand(); + Repository.UpdateData(locationInfos); + _unitOfWorkManage.CommitTran(); + } + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + return WebResponseContent.Instance.OK(); + } + /// <summary> + /// 鑾峰彇璐т綅缂栧彿 + /// </summary> + /// <param name="locationCode"></param> + /// <returns></returns> + string GetLocationCode(string locationCode) + { + var a = locationCode.Substring(0, 1); + var Row = a switch + { + "A" => "001", + "B" => "002", + "C" => "003", + "D" => "004", + "E" => "005", + _ => throw new Exception($"鏈畾涔夌殑鎺�,鍦板潃:銆恵locationCode}銆�"), + }; + var Column = locationCode.Substring(4, 2); + var Layer = locationCode.Substring(2, 2); + locationCode = "AGV_FL-" + Row + "-0" + Column + "-0" + Layer + "-01"; + return locationCode; + } + + /// <summary> /// 鍒濆鍖栬揣浣� /// </summary> /// <param name="initializationLocationDTO"></param> -- Gitblit v1.9.3