using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEA_Core.Enums; using WIDESEA_Core; using WIDESEA_Model.Models; using WIDESEA_Core.Helper; using Microsoft.Extensions.Logging; using MailKit.Search; using System.Reflection.Metadata; using static WIDESEA_ITaskInfoService.ITaskService; using Org.BouncyCastle.Bcpg; using WIDESEA_Model.Models.System; using Newtonsoft.Json; namespace WIDESEA_TaskInfoService { public partial class TaskService { public WebResponseContent PalletQueryinventory() { WebResponseContent content = new WebResponseContent(); List locationinfoData = _basicService.LocationInfoService.Repository.QueryData(x => x.RoadwayNo=="2" && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.LocationType == (int)LocationTypeEnum.EmptyCube && x.EnableStatus == (int)EnableStatusEnum.Normal); if (locationinfoData.Count < 20) { return content = WebResponseContent.Instance.OK(data: 1); } else { return content = WebResponseContent.Instance.OK(data: 3); } } public string ToWCSTask = WIDESEA_Core.Helper.AppSettings.Configuration["ToWCSTask"]; public WebResponseContent RequestInboundPDA(SaveModel saveModel) { WebResponseContent content = new WebResponseContent(); //查找货位信息,并修改 try { List taskdt = new List(); string barcode = saveModel.MainData["barcode"].ToString(); //条码 string stationName = saveModel.MainData["stationName"].ToString(); //车型 string cartnme = saveModel.MainData["cartnme"].ToString(); //名称 int cartcount = int.Parse(saveModel.MainData["cartcount"].ToString()); //数量 string barcodemodel = saveModel.MainData["barcodemodel"].ToString(); //车号 string cartnumber = saveModel.MainData["cartnumber"].ToString(); //车组号 Dt_LocationInfo newLocation; newLocation = _basicService.LocationInfoService.GetLocation("", 1); if (newLocation != null) { newLocation.LocationStatus = (int)LocationStatusEnum.Lock; //添加组盘库存信息 Dt_StockInfo dt_Stock = new() { PalletCode = barcode, IsFull = true, LocationCode = newLocation.LocationCode, StockStatus = (int)StockStatusEmun.组盘暂存, Creater = "WMS", CreateDate = DateTime.Now, MaterialType = (int)InventoryMaterialType.满托, Wlstatus = (int)InventoryMaterialStatus.待修, Materialweight = cartcount, WagonModel = barcodemodel, WagonName = cartnme, Wagonnumber = stationName, Wagongroup= cartnumber }; //生成入库任务 Dt_Task dt_Task = new() { PalletCode = barcode, TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), Roadway = newLocation.RoadwayNo, TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), SourceAddress = "1084", TargetAddress = newLocation.LocationCode, CurrentAddress = "1084", NextAddress = newLocation.LocationCode, Grade = 1, Depth = newLocation.Depth, MaterialType = (int)InventoryMaterialType.满托 }; BaseDal.AddData(dt_Task); _stockService.StockInfoService.Repository.AddData(dt_Stock); _basicService.LocationInfoService.UpdateData(newLocation); taskdt.Add(dt_Task); //调取wcs接口传递任务 WebResponseContent webResponseContent = HttpHelper.Post(ToWCSTask, taskdt, "入库任务下发"); if (webResponseContent.Status) { return content.OK("已添加入库任务"); } else { return content.Error("入库任务,下发WCS失败"); } } else { return content.Error("已无可用的货架,无法入库"); } } catch (Exception ex) { return content.Error($"入库添加失败,系统错误:{ex.Message}"); throw; } } /// /// 空托入库 /// /// /// public WebResponseContent EmptyInbound(GenerateInv saveModel) { WebResponseContent content = new WebResponseContent(); //查找货位信息,并修改 try { if (saveModel.barcode != null && saveModel.barcode.ToString() != "") { Dt_traycodeinfo _Traycodeinfo= _sys_Traycodeinfo.GetInCacheList(saveModel.barcode.ToString()); if(_Traycodeinfo!=null) { Dt_LocationInfo newLocation; newLocation = _basicService.LocationInfoService.GetLocation("", 1); if (newLocation != null) { newLocation.LocationStatus = (int)LocationStatusEnum.PalletLock; //添加组盘库存信息 Dt_StockInfo dt_Stock = new() { PalletCode = saveModel.barcode.ToString(), IsFull = false, LocationCode = newLocation.LocationCode, StockStatus = (int)StockStatusEmun.组盘暂存, Creater = "WMS", CreateDate = DateTime.Now, MaterialType = (int)InventoryMaterialType.空托, Wlstatus = (int)InventoryMaterialStatus.空托, //Materialweight = int.Parse(_Traycodeinfo.traycode_type), Materialweight = 1, WagonModel = _Traycodeinfo.traycode_materiel, WagonName = _Traycodeinfo.traycode_name, }; //生成入库任务 Dt_Task dt_Task = new() { PalletCode = saveModel.barcode.ToString(), TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), Roadway = newLocation.RoadwayNo, TaskType = TaskTypeEnum.Inbound.ObjToInt(), TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), SourceAddress = saveModel.stationnum.ToString(), TargetAddress = newLocation.LocationCode, CurrentAddress = saveModel.stationnum.ToString(), NextAddress = newLocation.LocationCode, Grade = 1, Depth = newLocation.Depth, MaterialType = (int)InventoryMaterialType.空托, Creater = "WMS", CreateDate= DateTime.Now, }; BaseDal.AddData(dt_Task); _stockService.StockInfoService.Repository.AddData(dt_Stock); _basicService.LocationInfoService.UpdateData(newLocation); return content.OK(data: dt_Task); } else { return content.Error("已无可用的货架,无法入库"); } } else { return content.Error("未在托盘管理中找到该托盘"); } } else { return content.Error("申请入库的条码为空,入库失败!"); } } catch (Exception ex) { return content.Error($"入库添加失败,系统错误:{ex.Message}"); throw; } } /// /// 检修回库方法 /// /// /// public WebResponseContent MaintenanceStorage(GenerateInv saveModel) { WebResponseContent content = new WebResponseContent(); //查找货位信息,并修改 try { Dt_StockInfo stocktData = _stockService.StockInfoService.Repository.QueryFirst(x => x.StockStatus == (int)StockStatusEmun.检修中 && x.MaterialType == (int)InventoryMaterialType.满托 && x.PalletCode== saveModel.barcode.ToString()); if (stocktData != null) { stocktData.StockStatus = (int)StockStatusEmun.检修入库锁定; //生成入库任务 Dt_Task dt_Task = new() { PalletCode = saveModel.barcode.ToString(), TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), Roadway = "1", TaskType = TaskTypeEnum.PalletMaintenancein.ObjToInt(), TaskStatus = AGVTaskStatusEnum.AGVin_Executing.ObjToInt(), SourceAddress = saveModel.stationnum.ToString(), TargetAddress = stocktData.LocationCode, CurrentAddress = saveModel.stationnum.ToString(), NextAddress = stocktData.LocationCode, Grade = 1, Depth = 1, MaterialType = (int)InventoryMaterialType.满托, Creater="WMS", CreateDate = DateTime.Now, }; BaseDal.AddData(dt_Task); _stockService.StockInfoService.Repository.UpdateData(stocktData); //调取wcs接口传递任务 //WebResponseContent webResponseContent = HttpHelper.Post(ReceiveWCSTask, dt_Task, "入库任务下发"); return content.OK(data: dt_Task); } else { return content.Error($"未找到该托盘条码的库存,申请的托盘条码:{saveModel.barcode.ToString()},站台编号{saveModel.stationnum.ToString()}"); } } catch (Exception ex) { return content.Error($"入库添加失败,系统错误:{ex.Message}"); throw; } } } }