|  |  | 
 |  |  | using HslCommunication.WebSocket; | 
 |  |  | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; | 
 |  |  | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; | 
 |  |  | using SqlSugar; | 
 |  |  | using System; | 
 |  |  | 
 |  |  | 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 | 
 |  |  | 
 |  |  |     { | 
 |  |  |         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> | 
 |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <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(); | 
 |  |  |                         if (ContainerDetailsInfos.Count < 1) stockInfo.PalletType = PalletTypeEnum.Empty.ObjToInt(); | 
 |  |  |                         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 ?? DateTime.Parse(ProduceData).AddYears(2).ToString("yyyy-MM-dd"), | 
 |  |  |                                 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); | 
 |  |  |             if (locationCode.Length == 7) | 
 |  |  |                 Column = locationCode.Substring(5, 2); | 
 |  |  |             var Layer = locationCode.Substring(2, 2); | 
 |  |  |             locationCode = "AGV_FL-" + Row + "-0" + Column + "-0" + Layer + "-01"; | 
 |  |  |             return locationCode; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// åå§åè´§ä½ | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="initializationLocationDTO"></param> |