| | |
| | | using WIDESEA_Common; |
| | | using WIDESEA_DTO.Outbound; |
| | | using WIDESEA_Core.Utilities; |
| | | using System.Transactions; |
| | | using Microsoft.Data.SqlClient; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | Grade = 0, |
| | | Creater = "WMS", |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = "0", |
| | | NextAddress = "", |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = stockInfo.LocationCode, |
| | | TargetAddress = roadwayInfo.OutStationCode, |
| | |
| | | return (tasks, stockInfos, orderDetail == null ? null : new List<Dt_OutboundOrderDetail> { orderDetail }, outStockLockInfos, locationInfos); |
| | | } |
| | | /// <summary> |
| | | /// 出库单据,出库任务下发 |
| | | /// 立库出库指令上传,出库任务下发 |
| | | /// </summary> |
| | | /// <param name="orderAddDTO"></param> |
| | | /// <returns></returns> |
| | |
| | | orderAddDTO1.InoutType = orderAddDTO.OrderType; |
| | | orderAddDTO1.OrderType = orderAddDTO.InoutType.ObjToInt(); |
| | | IEnumerable<int> inOrderTypes = Enum.GetValues<OrderTypeEmun>().Cast<int>(); |
| | | |
| | | //orderAddDTO1.OrderType = orderAddDTO.OrderType.ObjToInt(); |
| | | orderAddDTO1.Details = orderAddDTO.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>(); |
| | | #region 验证数据 |
| | |
| | | inboundOrder.OrderStatus = InboundStatusEnum.未开始.ObjToInt(); |
| | | inboundOrder.Creater = "WMS"; |
| | | inboundOrder.CreateDate = DateTime.Now; |
| | | bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | |
| | | |
| | | Dt_OutboundOrder oldOutboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == orderAddDTO1.OrderNo).Includes(x => x.Details).First(); |
| | | Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == oldOutboundOrder.Id); |
| | | List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | |
| | | LinId = outboundOrderDetail.LinId, |
| | | PalletCode = outboundOrderDetail.LPNNo, |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | stockSelectViews.Add(stockSelectViewDTO); |
| | | |
| | | //stockSelectViewDTO.PalletCode = orderAddDTO1; |
| | | //stockSelectViewDTO.LocationCode = orderAddDTO1; |
| | | |
| | | GenerateOutboundTasks(oldOutboundOrder.Id, stockSelectViews); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// 盘点出库 |
| | | /// 盘点任务上传立库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent InventoryOut(HouseCancelOut houseInventoryOut) |
| | |
| | | { |
| | | OutboundOrderAddDTO orderAddDTO1 = new OutboundOrderAddDTO(); |
| | | orderAddDTO1.OrderNo = houseInventoryOut.No; |
| | | orderAddDTO1.UpperOrderNo = houseInventoryOut.No; |
| | | orderAddDTO1.Details = houseInventoryOut.DetailList.DicToIEnumerable<OutboundOrderDetailAddDTO>(); |
| | | #region 验证数据 |
| | | (bool, string, object?) result = CheckOutboundOrderAddData(orderAddDTO1); |
| | |
| | | inboundOrder.OrderType = OutOrderTypeEnum.OutInventory.ObjToInt(); |
| | | inboundOrder.Creater = "WMS"; |
| | | inboundOrder.CreateDate = DateTime.Now; |
| | | bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | |
| | | Dt_OutboundOrder oldOutboundOrder = BaseDal.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == orderAddDTO1.OrderNo).Includes(x => x.Details).First(); |
| | | Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == oldOutboundOrder.Id); |
| | | List<StockSelectViewDTO> stockSelectViews = new List<StockSelectViewDTO>(); |
| | |
| | | BatchNo = outboundOrderDetail.BatchNo, |
| | | LinId = outboundOrderDetail.LinId, |
| | | }; |
| | | _unitOfWorkManage.BeginTran(); |
| | | bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand(); |
| | | stockSelectViews.Add(stockSelectViewDTO); |
| | | |
| | | //stockSelectViewDTO.PalletCode = orderAddDTO1; |
| | | //stockSelectViewDTO.LocationCode = orderAddDTO1; |
| | | GenerateOutboundTasks(oldOutboundOrder.Id, stockSelectViews); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | |
| | | } |
| | | private (bool, string, object?) CheckOutboundOrderAddData(OutboundOrderAddDTO outboundOrderAddDTO) |
| | | { |
| | | //(bool, string, object?) result1 = ModelValidate.ValidateModelData(outboundOrderAddDTO); |
| | | //if (!result1.Item1) return result1; |
| | | (bool, string, object?) result1 = ModelValidate.ValidateModelData(outboundOrderAddDTO); |
| | | if (!result1.Item1) return result1; |
| | | |
| | | //(bool, string, object?) result2 = ModelValidate.ValidateModelData(outboundOrderAddDTO.Details); |
| | | //if (!result2.Item1) return result2; |
| | | (bool, string, object?) result2 = ModelValidate.ValidateModelData(outboundOrderAddDTO.Details); |
| | | if (!result2.Item1) return result2; |
| | | |
| | | IEnumerable<int> inOrderTypes = Enum.GetValues<OutOrderTypeEnum>().Cast<int>(); |
| | | if (!inOrderTypes.Contains(outboundOrderAddDTO.OrderType)) |
| | |
| | | } |
| | | |
| | | } |
| | | public WebResponseContent RelocationTasks(List<Dt_Task> task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | for (int i = 0; i < task.Count; i++) |
| | | { |
| | | Dt_LocationInfo location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task[i].SourceAddress && x.RoadwayNo == task[i].Roadway); |
| | | if (location != null) |
| | | { |
| | | //(Dt_LocationInfo?, int?) result = _basicService.LocationInfoService.isDepth(location); |
| | | (Dt_LocationInfo?, int?) result = isDepth(location); |
| | | if (result.Item1 != null && result.Item2 != LocationStatusEnum.Lock.ObjToInt() && result.Item2 != LocationStatusEnum.PalletLock.ObjToInt() && result.Item2 != LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | int sum = 0; |
| | | for (int j = 0; j < task.Count; j++) |
| | | { |
| | | if (result.Item1.LocationCode == task[j].SourceAddress) |
| | | { |
| | | sum++; |
| | | } |
| | | } |
| | | if (sum == 0) |
| | | { |
| | | return content = RelocationTask(task[i]); |
| | | } |
| | | else |
| | | { |
| | | BaseDal.AddData(task[i]); |
| | | _basicService.LocationInfoService.UpdateLocationLock(location, task[i].TaskNum, StockChangeType.Outbound.ObjToInt(), true); |
| | | } |
| | | } |
| | | else if (result.Item1 == null && result.Item2 == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | BaseDal.AddData(task[i]); |
| | | location.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else if (result.Item1 != null && result.Item2 == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | BaseDal.AddData(task[i]); |
| | | location.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | _basicService.LocationInfoService.UpdateLocationLock(location, task[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else if (result.Item1 != null && (result.Item2 == LocationStatusEnum.Lock.ObjToInt() || result.Item2 == LocationStatusEnum.PalletLock.ObjToInt())) |
| | | { |
| | | Dt_Task TaskInfo = BaseDal.QueryFirst(x => x.SourceAddress == result.Item1.LocationCode); |
| | | if (TaskInfo == null) |
| | | { |
| | | return content = WebResponseContent.Instance.Error("货位被锁定不可出库"); |
| | | } |
| | | else |
| | | { |
| | | BaseDal.AddData(task[i]); |
| | | location.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.OK("任务异常"); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 移库任务 |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RelocationTask(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); |
| | | if (locationInfo != null) |
| | | { |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | //(Dt_LocationInfo?,int?) Result = _basicService.LocationInfoService.isDepth(locationInfo); |
| | | (Dt_LocationInfo?, int?) Result = isDepth(locationInfo); |
| | | if (Result.Item1 != null && Result.Item2 == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == Result.Item1.LocationCode); |
| | | Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfo.Id); |
| | | if (stockInfo != null && stockInfoDetail != null) |
| | | { |
| | | (Dt_Task?, Dt_LocationInfo?) result = AddRelocationTask(Result.Item1, stockInfo, task); |
| | | if (result.Item1 != null && result.Item2 != null) |
| | | { |
| | | _basicService.LocationInfoService.RelocationLock(Result.Item1, result.Item2, result.Item1.TaskNum); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(locationInfo); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Relocation.ObjToInt(), "", task.TaskNum); |
| | | return content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("移库任务生成失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("未找到库存信息"); |
| | | } |
| | | } |
| | | else if (Result.Item1 != null && Result.Item2 == LocationStatusEnum.Pallet.ObjToInt()) |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == Result.Item1.LocationCode); |
| | | if (stockInfo != null) |
| | | { |
| | | (Dt_Task?, Dt_LocationInfo?) result = AddRelocationTask(Result.Item1, stockInfo, task); |
| | | if (result.Item1 != null && result.Item2 != null) |
| | | { |
| | | _basicService.LocationInfoService.RelocationLock(Result.Item1, result.Item2, result.Item1.TaskNum); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(locationInfo); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Relocation.ObjToInt(), "", task.TaskNum); |
| | | return content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("移库任务生成失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("未找到库存信息"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("异常"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("任务信息异常"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断巷道内移库 |
| | |
| | | { |
| | | Locationtype = 10; |
| | | } |
| | | //newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo,Locationtype); //拿到了移库后的货位 |
| | | newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype); //拿到了移库后的货位 |
| | | if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.成品) |
| | | { |
| | | string[] targetCodesst = dt_StockInfo.PalletCode.Split("*"); |
| | | Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.OrderName == targetCodesst[0]); |
| | | if (dt_Inbound.Startingcolumn != 0 || dt_Inbound.Terminationcolumn != 0) |
| | | { |
| | | newLocation = _basicService.LocationInfoService.GetLocation2(locationInfos.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn); |
| | | } |
| | | else |
| | | { |
| | | newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype); |
| | | } |
| | | //Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.OrderName == targetCodesst[0]); |
| | | //if (dt_Inbound.Startingcolumn != 0 || dt_Inbound.Terminationcolumn != 0) |
| | | //{ |
| | | // newLocation = _basicService.LocationInfoService.GetLocation2(locationInfos.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn); |
| | | //} |
| | | //else |
| | | //{ |
| | | // newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype); |
| | | //} |
| | | |
| | | } |
| | | else |
| | |
| | | |
| | | public string ReceiveWMSTask = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSTask"]; |
| | | |
| | | |
| | | ///// <summary> |
| | | ///// 接收起点需要的空托盘进行出库 |
| | | ///// </summary> |
| | | ///// <param name="SourceAddress"></param> |
| | | ///// <returns></returns> |
| | | //public WebResponseContent Empty_outbound(GenerateInv generate) |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // try |
| | | // { |
| | | // Dt_Task task = BaseDal.QueryFirst(x => x.TargetAddress == generate.SourceAddress); |
| | | // if (task == null) |
| | | // { |
| | | // string RoadwayNo = "1"; |
| | | // if (generate.SourceAddress != "R01-002-041-001-01") |
| | | // { |
| | | // RoadwayNo = "2"; |
| | | // } |
| | | // Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.RoadwayNo == RoadwayNo && x.EnableStatus != (int)EnableStatusEnum.Disable && x.Depth==1 && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()); |
| | | // if(locationInfos == null) |
| | | // { |
| | | // locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.RoadwayNo == RoadwayNo && x.Depth == 2 && x.EnableStatus != (int)EnableStatusEnum.Disable && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()); |
| | | // } |
| | | |
| | | // if (locationInfos != null) |
| | | // { |
| | | // Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == locationInfos.LocationCode); |
| | | // if (dt_StockInfo != null && dt_StockInfo.MaterialType == (int)InventoryMaterialType.空托) |
| | | // { |
| | | |
| | | |
| | | // Dt_LocationInfo newSourceAddress; |
| | | // newSourceAddress = _basicService.LocationInfoService.GetLocationplatform(generate.SourceAddress); |
| | | // if (newSourceAddress != null) |
| | | // { |
| | | // Dt_Task dt_Task = new() |
| | | // { |
| | | // PalletCode = dt_StockInfo.PalletCode, |
| | | // TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | // Roadway = locationInfos.RoadwayNo, |
| | | // TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(), |
| | | // TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), |
| | | // SourceAddress = locationInfos.LocationCode, |
| | | // TargetAddress = newSourceAddress.LocationCode, |
| | | // CurrentAddress = locationInfos.LocationCode, |
| | | // NextAddress = newSourceAddress.LocationCode, |
| | | // Grade = 1, |
| | | // Creater = "WMS", |
| | | // Depth = locationInfos.Depth, |
| | | // CreateDate = DateTime.Now, |
| | | // PalletCodequantity = (int)dt_StockInfo.Materialweight, |
| | | // MaterialType = dt_StockInfo.MaterialType |
| | | // }; |
| | | |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // dt_StockInfo.StockStatus = (int)StockStatusEmun.出库锁定; |
| | | // dt_StockInfo.Remark = "等待堆垛机完成出库任务"; |
| | | // if (locationInfos.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) |
| | | // { |
| | | // locationInfos.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); |
| | | // } |
| | | // BaseDal.AddData(dt_Task); |
| | | // _basicService.LocationInfoService.UpdateData(locationInfos); |
| | | // _stockService.StockInfoService.Repository.UpdateData(dt_StockInfo); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | |
| | | // return content = WebResponseContent.Instance.OK(data: dt_Task); |
| | | // } |
| | | // else |
| | | // { |
| | | // return content = WebResponseContent.Instance.Error($"未找到站台编号,编号:{generate.SourceAddress}"); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // return content = WebResponseContent.Instance.Error($"无该库位空托为库存信息,库位编号:{locationInfos.LocationCode}"); |
| | | // } |
| | | |
| | | // } |
| | | // else |
| | | // { |
| | | // return content = WebResponseContent.Instance.Error($"该巷道已无空托盘,巷道号:{RoadwayNo}巷道"); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // return content = WebResponseContent.Instance.Error($"已有该站台的空托出库任务,站台编号{generate.SourceAddress}"); |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // _unitOfWorkManage.RollbackTran(); |
| | | // return content = WebResponseContent.Instance.Error($"出库失败,报错信息:{ex.Message}"); |
| | | // throw; |
| | | // } |
| | | //} |
| | | |
| | | |
| | | ///// <summary> |
| | | ///// 接收起点需要的空托盘进行出库 |
| | | ///// </summary> |
| | | ///// <param name="SourceAddress"></param> |
| | | ///// <returns></returns> |
| | | //public WebResponseContent Rawmaterialout(GenerateInv3 generate) |
| | | //{ |
| | | // WebResponseContent content = new WebResponseContent(); |
| | | // List<Dt_StockInfo> dt_StockInfo = _stockService.StockInfoService.Repository.QueryData(x => x.PalletCode.Contains(generate.PalletCode) && x.MaterialType== (int)InventoryMaterialType.原材料).OrderBy(x=>x.CreateDate).Take(generate.outCount).ToList(); |
| | | |
| | | // if(dt_StockInfo.Count > 0) |
| | | // { |
| | | // for (int i = 0; i < dt_StockInfo.Count; i++) |
| | | // { |
| | | // Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == dt_StockInfo[i].LocationCode); //确认货位信息是否对上 |
| | | // if (locationinfo != null) |
| | | // { |
| | | // Dt_Task dt_Task = new() |
| | | // { |
| | | // PalletCode = dt_StockInfo[i].PalletCode, |
| | | // TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | // Roadway = locationinfo.RoadwayNo, |
| | | // TaskType = TaskTypeEnum.Outbound.ObjToInt(), |
| | | // TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), |
| | | // SourceAddress = locationinfo.LocationCode, |
| | | // TargetAddress = locationinfo.RoadwayNo == "1" ? "R01-002-041-011-01" : "R02-002-027-011-01", |
| | | // CurrentAddress = locationinfo.LocationCode, |
| | | // NextAddress = locationinfo.RoadwayNo == "1" ? "R01-002-041-011-01" : "R02-002-027-011-01", |
| | | // Grade = 1, |
| | | // Creater = "WMS", |
| | | // Depth = locationinfo.Depth, |
| | | // CreateDate = DateTime.Now, |
| | | // PalletCodequantity = (int)dt_StockInfo[i].Materialweight, |
| | | // PLCTo = generate.TargetAddress == "R01-002-041-011-01" ? 1 : 2, |
| | | // MaterialType = dt_StockInfo[i].MaterialType |
| | | // }; |
| | | |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // dt_StockInfo[i].StockStatus = (int)StockStatusEmun.出库锁定; |
| | | // dt_StockInfo[i].Remark = "等待堆垛机完成出库任务"; |
| | | // if (locationinfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | // { |
| | | // locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | // } |
| | | // BaseDal.AddData(dt_Task); |
| | | // _basicService.LocationInfoService.UpdateData(locationinfo); |
| | | // _stockService.StockInfoService.Repository.UpdateData(dt_StockInfo); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | |
| | | // content = WebResponseContent.Instance.OK(data: dt_Task); |
| | | // } |
| | | // else |
| | | // { |
| | | // content = WebResponseContent.Instance.Error($"物料信息与货位信息不对,托盘号:{dt_StockInfo[i].PalletCode}"); |
| | | // } |
| | | // } |
| | | // return content; |
| | | // } |
| | | // else |
| | | // { |
| | | // return content = WebResponseContent.Instance.Error($"未找到出库的库存信息"); |
| | | // } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 手动生成出库任务 |
| | | /// </summary> |
| | | /// <param name="PalletCode"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ManualOutbound(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); |
| | | List<Dt_LocationInfo> locations = new List<Dt_LocationInfo>(); |
| | | List<Dt_Task> taskdt = new List<Dt_Task>(); |
| | | List<Dt_StockInfoDetail> dtstocktdetail = new List<Dt_StockInfoDetail>(); |
| | | for (int i = 0; i < saveModel.DelKeys.Count; i++) |
| | | { |
| | | Dt_StockInfo stockt = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == saveModel.DelKeys[i].ToString()); |
| | | if (stockt.StockStatus == (int)StockStatusEmun.已入库 && (stockt.Wlstatus == (int)InventoryMaterialStatus.合格 || stockt.Wlstatus == (int)InventoryMaterialStatus.返工)) |
| | | { |
| | | if (stockt.MaterialType != (int)InventoryMaterialType.原材料) |
| | | { |
| | | Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockt.Id); |
| | | stockt.StockStatus = (int)StockStatusEmun.出库锁定; |
| | | if (stockt.MaterialType != (int)InventoryMaterialType.空托) |
| | | { |
| | | stocktdetail.Status = (int)StockStatusEmun.出库锁定; |
| | | } |
| | | Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockt.LocationCode); |
| | | if (locationinfo.RoadwayNo == "1") |
| | | { |
| | | if (locationinfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | } |
| | | else if (locationinfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) |
| | | { |
| | | locationinfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); |
| | | } |
| | | string LocationName = "R01-002-044-001-01"; |
| | | if (stockt.MaterialType == (int)InventoryMaterialType.空托) |
| | | { |
| | | LocationName = "R01-002-043-001-01"; |
| | | } |
| | | Dt_LocationInfo newTargetAddress; |
| | | newTargetAddress = _basicService.LocationInfoService.GetLocationplatform(LocationName); |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | PalletCode = stockt.PalletCode, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Roadway = newTargetAddress.RoadwayNo, |
| | | TaskType = TaskTypeEnum.Outbound.ObjToInt(), |
| | | TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), |
| | | SourceAddress = locationinfo.LocationCode, |
| | | TargetAddress = newTargetAddress.LocationCode, |
| | | CurrentAddress = locationinfo.LocationCode, |
| | | NextAddress = newTargetAddress.LocationCode, |
| | | Grade = 1, |
| | | Creater = "WMS", |
| | | Depth = locationinfo.Depth, |
| | | CreateDate = DateTime.Now, |
| | | MaterialType = stockt.MaterialType |
| | | }; |
| | | dtstockt.Add(stockt); |
| | | locations.Add(locationinfo); |
| | | taskdt.Add(dt_Task); |
| | | if (stockt.MaterialType != (int)InventoryMaterialType.空托) |
| | | { |
| | | dtstocktdetail.Add(stocktdetail); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,只可出库1巷道的托盘和成品,出库条码:{saveModel.DelKeys[i].ToString()}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,请不要选择原材料出库,出库条码:{saveModel.DelKeys[i].ToString()}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,请选择已入库且合格的物料出库!!!,出库条码:{saveModel.DelKeys[i].ToString()}"); |
| | | } |
| | | |
| | | } |
| | | var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, taskdt, "下发任务入库"); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (dtstockt.Count > 0) |
| | | { |
| | | _stockService.StockInfoService.Repository.UpdateData(dtstockt); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(dtstocktdetail); |
| | | _basicService.LocationInfoService.Repository.UpdateData(locations); |
| | | BaseDal.AddData(taskdt); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK(); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content = WebResponseContent.Instance.Error($"出库失败,报错信息:{ex.Message}"); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | |
| | | public WebResponseContent ManualOutbound2(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); |
| | | List<Dt_LocationInfo> locations = new List<Dt_LocationInfo>(); |
| | | List<Dt_Task> taskdt = new List<Dt_Task>(); |
| | | List<Dt_StockInfoDetail> dtstocktdetail = new List<Dt_StockInfoDetail>(); |
| | | |
| | | |
| | | List<Dt_StockInfo> stocktData = _stockService.StockInfoService.Repository.QueryData(x => x.StockStatus == (int)StockStatusEmun.已入库 && x.MaterialType == (int)InventoryMaterialType.原材料); |
| | | List<Dt_LocationInfo> locationinfoData = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()); |
| | | List<Dt_StockInfoDetail> StockInfoDetailData = _stockService.StockInfoDetailService.Repository.QueryData(x => x.Status == (int)StockStatusEmun.已入库); |
| | | |
| | | |
| | | string json = saveModel.DelKeys[0].ToString(); |
| | | List<string> palletCodes = JsonConvert.DeserializeObject<List<string>>(json); |
| | | |
| | | foreach (var palletCode in palletCodes) |
| | | { |
| | | Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.PalletCode == palletCode); |
| | | if (stockt != null) |
| | | { |
| | | if (stockt.StockStatus == (int)StockStatusEmun.已入库 && (stockt.Wlstatus == (int)InventoryMaterialStatus.合格 || stockt.Wlstatus == (int)InventoryMaterialStatus.退货 || stockt.Wlstatus == (int)InventoryMaterialStatus.特采)) |
| | | { |
| | | Dt_StockInfoDetail stocktdetail = StockInfoDetailData.FirstOrDefault(x => x.StockId == stockt.Id); |
| | | if (stocktdetail != null) |
| | | { |
| | | Dt_LocationInfo locationinfo = locationinfoData.FirstOrDefault(x => x.LocationCode == stockt.LocationCode); |
| | | if (locationinfo != null) |
| | | { |
| | | stockt.StockStatus = (int)StockStatusEmun.出库锁定; |
| | | if (locationinfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | locationinfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | } |
| | | |
| | | string TargetAdd = ""; |
| | | if (saveModel.DelKeys[1].ToString() == "20") |
| | | { |
| | | TargetAdd = "R02-001-021-001-02"; |
| | | } |
| | | else if (saveModel.DelKeys[1].ToString() == "30") |
| | | { |
| | | TargetAdd = "R02-001-022-001-02"; |
| | | } |
| | | else if (saveModel.DelKeys[1].ToString() == "40") |
| | | { |
| | | TargetAdd = "R01-002-044-001-01"; |
| | | } |
| | | else |
| | | { |
| | | TargetAdd = locationinfo.RoadwayNo == "2" ? "R02-002-027-011-01" : "R01-002-041-011-01"; |
| | | } |
| | | |
| | | |
| | | Dt_Task dt_Task = new() |
| | | { |
| | | PalletCode = stockt.PalletCode, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)), |
| | | Roadway = locationinfo.RoadwayNo, |
| | | TaskType = TaskTypeEnum.Outbound.ObjToInt(), |
| | | TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), |
| | | SourceAddress = locationinfo.LocationCode, |
| | | TargetAddress = TargetAdd, |
| | | CurrentAddress = locationinfo.LocationCode, |
| | | NextAddress = TargetAdd, |
| | | Grade = 1, |
| | | Creater = "WMS", |
| | | Depth = locationinfo.Depth, |
| | | CreateDate = DateTime.Now, |
| | | PLCTo = int.Parse(saveModel.DelKeys[1].ToString()), |
| | | MaterialType = stockt.MaterialType |
| | | }; |
| | | dtstockt.Add(stockt); |
| | | locations.Add(locationinfo); |
| | | taskdt.Add(dt_Task); |
| | | dtstocktdetail.Add(stocktdetail); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,未找到对应的库位信息,请核对!!!,出库条码:{palletCode}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,未找到对应的库存详情信息,请核对!!!,出库条码:{palletCode}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,请选择已入库且(合格,特采,退货)的物料出库!!!,出库条码:{palletCode}"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,未找到对应条码的库存信息,出库条码:{palletCode}"); |
| | | |
| | | } |
| | | } |
| | | var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, taskdt, "下发任务入库"); |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (dtstockt.Count > 0) |
| | | { |
| | | _stockService.StockInfoService.Repository.UpdateData(dtstockt); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(dtstocktdetail); |
| | | _basicService.LocationInfoService.Repository.UpdateData(locations); |
| | | BaseDal.AddData(taskdt); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK($"出库成功,出库总数:{palletCodes.Count},成功数量:{dtstockt.Count}"); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content = WebResponseContent.Instance.Error($"出库失败,报错信息:{ex.Message}"); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent ManualOutbound3(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); |
| | | |
| | | |
| | | List<Dt_StockInfo> stocktData = _stockService.StockInfoService.Repository.QueryData(x => x.StockStatus == (int)StockStatusEmun.已入库); |
| | | string json = saveModel.DelKeys[0].ToString(); |
| | | List<int> palletCodes = JsonConvert.DeserializeObject<List<int>>(json); |
| | | |
| | | foreach (int pallid in palletCodes) |
| | | { |
| | | Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.Id == pallid); |
| | | if (stockt != null) |
| | | { |
| | | |
| | | stockt.Wlstatus = int.Parse(saveModel.DelKeys[1].ToString()); |
| | | dtstockt.Add(stockt); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"修改失败,未找到对应的库存信息,库存编号:{pallid}"); |
| | | |
| | | } |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (dtstockt.Count > 0) |
| | | { |
| | | _stockService.StockInfoService.Repository.UpdateData(dtstockt); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK($"修改成功"); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content = WebResponseContent.Instance.Error($"修改失败,报错信息:{ex.Message}"); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent ManualOutbound4(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); |
| | | |
| | | |
| | | List<Dt_StockInfo> stocktData = _stockService.StockInfoService.Repository.QueryData(x => x.StockStatus == (int)StockStatusEmun.已入库); |
| | | string json = saveModel.DelKeys[0].ToString(); |
| | | List<int> palletCodes = JsonConvert.DeserializeObject<List<int>>(json); |
| | | |
| | | foreach (int pallid in palletCodes) |
| | | { |
| | | Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.Id == pallid); |
| | | if (stockt != null) |
| | | { |
| | | |
| | | stockt.Mgeneratetime = DateTime.Parse(saveModel.DelKeys[1].ToString()); |
| | | dtstockt.Add(stockt); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"修改失败,未找到对应的库存信息,库存编号:{pallid}"); |
| | | |
| | | } |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (dtstockt.Count > 0) |
| | | { |
| | | _stockService.StockInfoService.Repository.UpdateData(dtstockt); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK($"修改成功"); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content = WebResponseContent.Instance.Error($"修改失败,报错信息:{ex.Message}"); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | public class PalletCodeList |
| | | { |
| | | public string PalletCode { get; set; } |
| | | } |
| | | |
| | | |
| | | public (Dt_Task?, Dt_LocationInfo?) AddRelocationTask(Dt_LocationInfo location, Dt_StockInfo stockInfo, Dt_Task task) |
| | | { |
| | | Dt_LocationInfo? locationInfos = _basicService.LocationInfoService.AssignLocation(location.RoadwayNo); |
| | | if (locationInfos != null) |
| | | { |
| | | Dt_Task tasks = new() |
| | | { |
| | | CurrentAddress = location.LocationCode, |
| | | Grade = 0, |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = locationInfos.LocationCode, |
| | | Roadway = location.RoadwayNo, |
| | | SourceAddress = location.LocationCode, |
| | | TargetAddress = locationInfos.LocationCode, |
| | | TaskStatus = InTaskStatusEnum.RelocationNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Relocation.ObjToInt(), |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)) |
| | | }; |
| | | BaseDal.AddData(tasks); |
| | | BaseDal.AddData(task); |
| | | stockInfo.StockStatus = StockStatusEmun.移库锁定.ObjToInt(); |
| | | _stockService.StockInfoService.UpdateData(stockInfo); |
| | | } |
| | | return (task, locationInfos); |
| | | } |
| | | /// <summary> |
| | | /// 生成出库任务 |
| | | /// </summary> |
| | |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 空托盘出库任务 |
| | | /// </summary> |
| | | /// <param name="inTask"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent PalletOutboundTask(string roadwayNo, string endStation) |
| | | { |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetPalletStockInfo(roadwayNo); |
| | | if (stockInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到空托盘库存"); |
| | | } |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode && x.RoadwayNo == roadwayNo); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到空托盘库存对应的货位信息"); |
| | | } |
| | | Dt_RoadwayInfo roadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.InStationCode == endStation && x.RoadwayNo == roadwayNo); |
| | | if (roadwayInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("未找到终点巷道信息"); |
| | | } |
| | | Dt_Task task = new Dt_Task() |
| | | { |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | Grade = 0, |
| | | NextAddress = endStation, |
| | | PalletCode = stockInfo.PalletCode, |
| | | Roadway = roadwayNo, |
| | | SourceAddress = stockInfo.LocationCode, |
| | | TargetAddress = endStation, |
| | | TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(), |
| | | Depth = locationInfo.Depth, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)) |
| | | |
| | | }; |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | _unitOfWorkManage.BeginTran(); |
| | | stockInfo.StockStatus = StockStatusEmun.出库锁定.ObjToInt(); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | BaseDal.AddData(task); |
| | | _stockService.StockInfoService.UpdateData(stockInfo); |
| | | |
| | | _basicService.LocationInfoService.UpdateData(locationInfo); |
| | | |
| | | _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), "", task.TaskNum); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public (Dt_LocationInfo?, int?) isDepth(Dt_LocationInfo locationInfo) |
| | | { |
| | | if (locationInfo.Depth == 2) |
| | | { |
| | | if (locationInfo.Row == 1 || locationInfo.Row == 5) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.Row == locationInfo.Row + 1 && x.Layer == locationInfo.Layer && x.Column == locationInfo.Column && x.RoadwayNo == locationInfo.RoadwayNo); |
| | | |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.InStock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Free.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Lock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.PalletLock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Pallet.ObjToInt()); |
| | | } |
| | | } |
| | | else if (locationInfo.Row == 4 || locationInfo.Row == 8) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.Row == locationInfo.Row + 1 && x.Layer == locationInfo.Layer && x.Column == locationInfo.Column && x.RoadwayNo == locationInfo.RoadwayNo); |
| | | |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.InStock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Free.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Lock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.PalletLock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Pallet.ObjToInt()); |
| | | } |
| | | } |
| | | } |
| | | return (null, LocationStatusEnum.Free.ObjToInt()); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 人工手动出库(删除库存) |
| | | /// </summary> |
| | | /// <param name="saveModel"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ManualOutboundDeleteinventory(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>(); |
| | | List<Dt_LocationInfo> locations = new List<Dt_LocationInfo>(); |
| | | List<Dt_StockInfoDetail> dtstocktdetail = new List<Dt_StockInfoDetail>(); |
| | | |
| | | for (int i = 0; i < saveModel.DelKeys.Count; i++) |
| | | { |
| | | Dt_StockInfo stockt = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == saveModel.DelKeys[i].ToString()); |
| | | if (stockt.StockStatus == (int)StockStatusEmun.已入库) |
| | | { |
| | | Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockt.Id); |
| | | Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockt.LocationCode); |
| | | locationinfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); |
| | | dtstockt.Add(stockt); |
| | | locations.Add(locationinfo); |
| | | if (stockt.MaterialType == (int)InventoryMaterialType.空托) |
| | | { |
| | | dtstocktdetail.Add(stocktdetail); |
| | | } |
| | | WriteLog.GetLog("人工手动删除库存信息").Write($"托盘条码:{stockt.PalletCode},库位编号:{stockt.LocationCode}", $"人工出库库存"); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error($"出库失败,该库存信息不可进行出库"); |
| | | } |
| | | |
| | | } |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockService.StockInfoService.Repository.DeleteData(dtstockt); |
| | | if (dtstocktdetail.Count == 0) |
| | | { |
| | | _stockService.StockInfoDetailService.Repository.DeleteData(dtstocktdetail); |
| | | } |
| | | _basicService.LocationInfoService.Repository.UpdateData(locations); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content = WebResponseContent.Instance.OK(); |
| | | return content; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content = WebResponseContent.Instance.Error($"手动出库信息失败,报错信息:{ex.Message}"); |
| | | throw; |
| | | } |
| | | } |
| | | |