From cd78554c3da306ed8c866d971bee94457665f80c Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期六, 30 八月 2025 17:35:51 +0800 Subject: [PATCH] ERP一期接口 --- 项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs | 144 +++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 123 insertions(+), 21 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" index 1f7d0db..5692ab7 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs" @@ -53,7 +53,7 @@ { return WebResponseContent.Instance.Error($"鏈壘鍒扮粍鐩樹俊鎭�"); } - if (stockInfo.StockStatus != StockStatusEmun.閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()) + if (stockInfo.StockStatus != StockStatusEmun.MES浣欐枡閫�搴�.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()) { return WebResponseContent.Instance.Error($"璇ユ墭鐩樼姸鎬佷笉姝g‘,涓嶅彲鐢宠鍏ュ簱"); } @@ -81,22 +81,6 @@ if (stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鏆傚瓨.ObjToInt()) { stockInfo.StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(); - } - else if (stockInfo.StockStatus == StockStatusEmun.MES閫�搴�.ObjToInt()) - { - newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt(); - } - else if (stockInfo.StockStatus == StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()) - { - //todo 灏忔墭鐩樻殏鏃舵湭鍚敤 - if (stockInfo.PalletType == PalletTypeEnum.MediumPallet.ObjToInt()) - { - newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt(); - } - else - { - newTask.TaskType = TaskTypeEnum.MesPalletSmallReturn.ObjToInt(); - } } else { @@ -246,7 +230,7 @@ { agvstation.IsOccupied = WhetherEnum.False.ObjToInt(); } - Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == task.PalletCode); + Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x=>x.proStockInfoDetails).First(); if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.MES绌烘墭閫�搴�.ObjToInt()) { task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); @@ -258,6 +242,26 @@ proStockInfo.LocationCode = locationInfoEnd.LocationCode; proStockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); + _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚); + _unitOfWorkManage.CommitTran(); + } + else if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()) + { + task.TaskStatus = TaskStatusEnum.Finish.ObjToInt(); + proStockInfo.proStockInfoDetails.ForEach(x => + { + x.ProStockDetailStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); + }); + _unitOfWorkManage.BeginTran(); + if (agvstation != null) + { + _agvStationInfoRepository.UpdateData(agvstation); + } + proStockInfo.LocationCode = locationInfoEnd.LocationCode; + proStockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt(); + _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo); + _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails); _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚); _unitOfWorkManage.CommitTran(); @@ -339,6 +343,7 @@ throw new Exception(ex.Message); } } + /// <summary> /// 鍏ュ簱浠诲姟鐢宠鍒嗛厤璐т綅 /// </summary> @@ -376,7 +381,7 @@ { task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt(); } - + LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus; //鏇存柊閿佸畾璐т綅 @@ -521,6 +526,103 @@ } return content; } + private readonly static object _lockerFL = new object(); + /// <summary> + /// 杈呮枡鍏ュ簱 + /// </summary> + /// <returns></returns> + public WebResponseContent InboundFLTask(string barCode, string startPoint,string matCode,int matCount) + { + lock (_lockerFL) + { + WebResponseContent content = new WebResponseContent(); + try + { + //string palletCode = @"^C\d{5}$"; // 姝e垯琛ㄨ揪寮� + //bool isValid = Regex.IsMatch(barCode, palletCode); + //if (!isValid) + //{ + // return content.Error($"妗嗙爜鏍煎紡閿欒{barCode}"); + //} + Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == matCode && x.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt() && x.MaterielSourceType == MaterielTypeEnum.杈呮枡澶囦欢.ObjToInt()); + if (materielInfo == null) + { + return content.Error($"鏈壘鍒扮墿鏂欎俊鎭瘂matCode}"); + } + Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint); + if (agvstation == null) + { + return content.Error($"璧风偣閿欒{startPoint}"); + } + //鍒ゆ柇褰撳墠鐐逛綅鏄惁閲嶅 + Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Executing.ObjToInt())); + if (taskOldPoint != null) + { + return content.Error($"绔欑偣{startPoint}宸插瓨鍦ㄤ换鍔�"); + } + Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode); + if (taskOld != null) + { + return content.Error($"鎵樼洏{barCode}浠诲姟宸插瓨鍦�"); + } + Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode); + if (proStockInfoOld != null) + { + return content.Error($"鎵樼洏{barCode}宸插瓨鍦�"); + } + //鍒嗛厤宸烽亾 + string roadWay = AssignCPRoadwayNo(); + + //鑾峰彇鎴愬搧搴� + Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.LLDCP.ToString()); + Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail() + { + ProductCode = matCode, + StockQty = matCount, + ProStockDetailStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt() + }; + Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo() + { + PalletCode = barCode, + ProStockAttribute = ProStockAttributeEnum.杈呮枡澶囦欢.ObjToInt(), + PalletType = 1, + LocationCode = "", + WarehouseId = warehouse.WarehouseId, + StockStatus = StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt(), + proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail } + }; + + Dt_Task newTask = new Dt_Task() + { + CurrentAddress = startPoint, + Grade = 0, + NextAddress = "", + PalletCode = barCode, + Roadway = roadWay, + SourceAddress = startPoint, + TargetAddress = "", + TaskType = TaskTypeEnum.Inbound.ObjToInt(), + TaskStatus = TaskStatusEnum.New.ObjToInt(), + WarehouseId = warehouse.WarehouseId, + PalletType = 1 + }; + _unitOfWorkManage.BeginTran(); + int taskId = BaseDal.AddData(newTask); + BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand(); + newTask.TaskId = taskId; + _unitOfWorkManage.CommitTran(); + //鎺ㄩ�佷换鍔� + PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV"); + content.OK("鍙戦�佹垚鍔�"); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + content.Error(ex.Message); + } + return content; + } + } /// <summary> /// 鍗板埛浣欐枡閫�鏂欎换鍔� /// </summary> @@ -581,7 +683,7 @@ Roadway = "", SourceAddress = address, TargetAddress = "", - TaskType = TaskTypeEnum.PrintBackInbound.ObjToInt(), + TaskType = TaskTypeEnum.PrintYLBackInbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = warehouseId, PalletType = 1, @@ -667,7 +769,7 @@ Roadway = "", SourceAddress = address, TargetAddress = "", - TaskType = TaskTypeEnum.PrintInbound.ObjToInt(), + TaskType = TaskTypeEnum.PrintYLInbound.ObjToInt(), TaskStatus = TaskStatusEnum.New.ObjToInt(), WarehouseId = warehouseId, PalletType = 1, -- Gitblit v1.9.3