using iWareSql.MyDbContext; using System; using System.Collections.Generic; using System.Linq; namespace iWareCC.Common.Helper { public class BaseInfoHelper { /// /// 获取容器 /// /// /// /// /// public static wms_base_container GetContainer(MyDbContext mycontext, string containerCode, ref string errMsg) { var container = mycontext.wms_base_container.FirstOrDefault(f => f.ContainerCode == containerCode && f.IsDelete == false); if (container == null) { errMsg = $"容器号{containerCode}不存在"; throw new Exception(errMsg); } if (container.IsDisabled == true) { errMsg = $"容器号{containerCode}已禁用"; throw new Exception(errMsg); } return container; } /// /// 获取库位 /// /// /// /// /// /// public static wms_base_place GetPlace(MyDbContext mycontext, string placeCode, string remark, ref string errMsg) { var place = mycontext.wms_base_place.FirstOrDefault(f => f.PlaceCode == placeCode && f.IsDelete == false); if (place == null) { errMsg = $"{remark}{placeCode}不存在"; throw new Exception(errMsg); } if (place.IsDisabled == true) { errMsg = $"{remark}{placeCode}已禁用"; throw new Exception(errMsg); } //if (place.PlaceStatus != (int)PlaceStatusEnum.正常) //{ // errMsg = $"{remark}{placeCode}库位属性不是{PlaceStatusEnum.正常.ToString()}"; //} return place; } /// /// 获取库区 /// /// /// /// /// /// public static wms_base_area GetArea(MyDbContext mycontext, string areaCode, string remark, ref string errMsg) { var area = mycontext.wms_base_area.FirstOrDefault(f => f.AreaCode == areaCode && f.IsDelete == false); if (area == null) { errMsg = $"{remark}{areaCode}不存在"; throw new Exception(errMsg); } if (area.IsDisabled == true) { errMsg = $"{remark}{areaCode}已禁用"; throw new Exception(errMsg); } return area; } /// /// 获取移动单 /// /// /// /// /// public static wms_order_movement GetOrderMovement(MyDbContext mycontext, wms_task singleTask, ref string errMsg) { var moveOrder = mycontext.wms_order_movement.FirstOrDefault(x => singleTask.OrderNo.Equals(x.OrderNo) || singleTask.RelationNo.Equals(x.OrderNo)); if (moveOrder == null) { errMsg = $"单号{singleTask.RelationNo}\\{singleTask.OrderNo}未查询到移动单"; throw new Exception(errMsg); } return moveOrder; } /// /// 获取移动单明细 /// /// /// /// /// /// public static List GetMoveOrderDetails(MyDbContext mycontext, wms_task singleTask, wms_order_movement moveOrder, ref string errMsg) { var moveOrderDetails = mycontext.wms_order_movement_details.Where(x => x.MovementId == moveOrder.Id).ToList(); if (moveOrderDetails?.Count <= 0) { errMsg = $"单号{singleTask.OrderNo}移动单明细不存在"; throw new Exception(errMsg); } return moveOrderDetails; } } }