| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_DTO.MES; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent HandSubstrateOut(int orderId) |
| | | { |
| | | try |
| | | { |
| | | Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.Id == orderId); |
| | | if (mesOutboundOrder == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥è®¢å"); |
| | | } |
| | | |
| | | if (mesOutboundOrder.OrderStatus != OutOrderStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error($"该订åä¸å¯ååºåº"); |
| | | } |
| | | |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | |
| | | List<Dt_StockInfo>? stockInfos = null; |
| | | List<Dt_OutStockLockInfo>? outStockLockInfos = null; |
| | | List<Dt_LocationInfo>? locationInfos = null; |
| | | { |
| | | (List<Dt_StockInfo>, Dt_MesOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesOutboundOrderService.AssignStockOutbound(mesOutboundOrder); |
| | | if (result.Item1 != null && result.Item1.Count > 0) |
| | | { |
| | | tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); |
| | | result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); |
| | | result.Item3.ForEach(x => |
| | | { |
| | | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); |
| | | }); |
| | | |
| | | stockInfos = result.Item1; |
| | | mesOutboundOrder = result.Item2; |
| | | outStockLockInfos = result.Item3; |
| | | locationInfos = result.Item4; |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("æ åºå"); |
| | | } |
| | | } |
| | | |
| | | tasks.ForEach(x => |
| | | { |
| | | if (mesOutboundOrder.OrderType == MesOutboundOrderTypeEnum.HandSubstrateOut.ObjToInt()) |
| | | { |
| | | x.TaskType = TaskTypeEnum.MesHandOutbound.ObjToInt(); |
| | | } |
| | | else if (mesOutboundOrder.OrderType == MesOutboundOrderTypeEnum.HandSubstrateOutPick.ObjToInt()) |
| | | { |
| | | x.TaskType = TaskTypeEnum.MesHandPickOutbound.ObjToInt(); |
| | | } |
| | | }); |
| | | |
| | | mesOutboundOrder.OrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | |
| | | int id = BaseDal.AddData(tasks); |
| | | outStockLockInfos.ForEach(x => |
| | | { |
| | | x.OrderNo = mesOutboundOrder.TaskNo; |
| | | x.OrderDetailId = id; |
| | | }); |
| | | _outboundService.MesOutboundOrderService.Repository.UpdateData(mesOutboundOrder); |
| | | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) |
| | | { |
| | | WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (!content.Status) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(content.Message); |
| | | } |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public class LocationCount |
| | | { |
| | | public string RoadwayNo { get; set; } |
| | | |
| | | public int Count { get; set; } |
| | | } |
| | | } |
| | | } |