| | |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using System.Threading.Tasks; |
| | | using AutoMapper; |
| | | using HslCommunication.WebSocket; |
| | | using SqlSugar; |
| | |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.BasicInfo; |
| | | using WIDESEAWCS_DTO.PlacedBlockDTO; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using static Dm.net.buffer.ByteArrayBuffer; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | | public class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IMapper _mapper; |
| | | private readonly IContainerRepository _containerRepository; |
| | | private readonly IContainerItemRepository _containerItemRepository; |
| | | private readonly WebSocketServer _webSocketServer; |
| | | private readonly IOrderDetailsRepository _orderDetailsRepository; |
| | | private readonly IContainerService _containerService; |
| | | private readonly IOrderDetailsService _orderDetailsService; |
| | | private readonly IOrderrowsRepository _orderrowsRepository; |
| | | private readonly IOrderContainerRepository _orderContainerRepository; |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IContainerRepository containerRepository, IContainerItemRepository containerItemRepository, WebSocketServer webSocketServer, IOrderDetailsRepository orderDetailsRepository) : base(BaseDal) |
| | | public TaskService(ITaskRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IMapper mapper, IContainerRepository containerRepository, IContainerItemRepository containerItemRepository, WebSocketServer webSocketServer, IOrderDetailsRepository orderDetailsRepository, IContainerService containerService, IOrderDetailsService orderDetailsService, IOrderrowsRepository orderrowsRepository, IOrderContainerRepository orderContainerRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _mapper = mapper; |
| | | _containerRepository = containerRepository; |
| | | _containerItemRepository = containerItemRepository; |
| | | _webSocketServer = webSocketServer; |
| | | _orderDetailsRepository = orderDetailsRepository; |
| | | _containerService = containerService; |
| | | _orderDetailsService = orderDetailsService; |
| | | _orderrowsRepository = orderrowsRepository; |
| | | _orderContainerRepository = orderContainerRepository; |
| | | } |
| | | |
| | | public Dt_Task? QueryAGantryUnExecuteTask(string gantryDeviceNo) |
| | |
| | | return WebResponseContent.Instance.Error("æªæ¾å°è®¢åæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | |
| | | |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()); |
| | | if (putContainer == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æ¾è´§ä½ç½®ä¸åå¨"); |
| | | } |
| | | |
| | | ContainerSize containerSize = new ContainerSize(1500, putContainer.ContainerWidth, putContainer.ContainerHeight); |
| | | |
| | | List<PlacedBlock> placedBlocks = new List<PlacedBlock>(); |
| | | |
| | | for (int i = 0; i < orderDetails.Count; i++) |
| | |
| | | int width = Convert.ToInt32(orderDetails[i].Orderdetails_width); |
| | | int height = Convert.ToInt32(orderDetails[i].Orderdetails_thickness); |
| | | |
| | | TaskPosition taskPosition = new TaskPosition(); |
| | | taskPosition = GetTakePutPosition(length, width, height, containerSize, placedBlocks); |
| | | OrderInfo orderInfo = _orderDetailsService.GetOrderInfoByBarcode(orderDetails[i].Orderdetails_outid); |
| | | Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(x => x.OrderNo == orderInfo.OrderNo && x.ContainerCode == putContainer.ContainerCode); |
| | | |
| | | PlacedBlock placedBlock = new PlacedBlock(new Point3D(taskPosition.PositionX, taskPosition.PositionY, taskPosition.PositionZ), length, width, height); |
| | | placedBlocks.Add(placedBlock); |
| | | ContainerSize containerSize = new ContainerSize(putContainer.ContainerLength, putContainer.ContainerWidth, putContainer.ContainerHeight); |
| | | |
| | | object obj = new |
| | | int lengthThreshold = AppSettings.Get("LengthThreshold").ObjToInt(); |
| | | bool isAdd = false; |
| | | bool isUpdate = false; |
| | | if (orderContainer == null) |
| | | { |
| | | x = taskPosition.PutCenterPositionX - containerSize.Length / 2, |
| | | y = taskPosition.PutCenterPositionY - containerSize.Width / 2, |
| | | z = taskPosition.PutCenterPositionZ, |
| | | length, |
| | | width, |
| | | height, |
| | | }; |
| | | orderContainer = new Dt_OrderContainer() |
| | | { |
| | | OrderId = orderInfo.OrderHeadId, |
| | | ContainerCode = putContainer.ContainerCode, |
| | | ContainerId = putContainer.Id, |
| | | OrderNo = orderInfo.OrderNo, |
| | | }; |
| | | |
| | | _webSocketServer.PublishAllClientPayload(obj.Serialize()); |
| | | if (length > lengthThreshold) |
| | | { |
| | | orderContainer.MaxLength = putContainer.ContainerLength; |
| | | } |
| | | else |
| | | { |
| | | orderContainer.MaxLength = lengthThreshold; |
| | | } |
| | | isAdd = true; |
| | | } |
| | | else |
| | | { |
| | | if (length < lengthThreshold) |
| | | { |
| | | isUpdate = true; |
| | | orderContainer.MaxLength = lengthThreshold; |
| | | } |
| | | containerSize = new ContainerSize(orderContainer.MaxLength, putContainer.ContainerWidth, putContainer.ContainerHeight); |
| | | } |
| | | |
| | | Thread.Sleep(100); |
| | | |
| | | |
| | | TaskPosition? taskPosition = new TaskPosition(); |
| | | taskPosition = _containerService.GetTaskPosition(length, width, height, containerSize, placedBlocks); |
| | | |
| | | if (taskPosition != null) |
| | | { |
| | | |
| | | |
| | | |
| | | Dt_ContainerItem dt_ContainerItem = new Dt_ContainerItem() |
| | | { |
| | | ContainerId = putContainer.Id, |
| | | ItemCode = orderInfo.Barcode, |
| | | ItemLength = length, |
| | | ItemWidth = width, |
| | | ItemHeight = height, |
| | | ItemPositionX = taskPosition.PositionX, |
| | | ItemPositionY = taskPosition.PositionY, |
| | | ItemPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PositionX, |
| | | ItemRelaPositionY = taskPosition.PositionY, |
| | | ItemRelaPositionZ = taskPosition.PositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = orderInfo.Barcode |
| | | }; |
| | | |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | PalletCode = orderInfo.Barcode, |
| | | DeviceCode = putContainer.DeviceCode, |
| | | TaskState = (int)TaskStatusEnum.Gantry_Wait, |
| | | TaskType = 0, |
| | | SourceAddress = "", |
| | | TargetAddress = $"F06", |
| | | CurrentAddress = $"F06*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}", |
| | | NextAddress = $"{putContainer.ContainerCode}*{taskPosition.PutPositionX}*{taskPosition.PutPositionY}*{taskPosition.PutPositionZ}*{taskPosition.PositionR}", |
| | | ItemInfo = $"{length}*{width}*{height}", |
| | | Grade = 0, |
| | | }; |
| | | putContainer.ContainerStatus = ContainerStatusEnum.NonEmpty.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _containerRepository.UpdateData(putContainer); |
| | | _containerItemRepository.AddData(dt_ContainerItem); |
| | | if (isAdd) |
| | | { |
| | | _orderContainerRepository.AddData(orderContainer); |
| | | } |
| | | else if (isUpdate) |
| | | { |
| | | _orderContainerRepository.UpdateData(orderContainer); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | PlacedBlock placedBlock = new PlacedBlock(new Point3D(taskPosition.PositionX, taskPosition.PositionY, taskPosition.PositionZ), length, width, height); |
| | | placedBlocks.Add(placedBlock); |
| | | |
| | | object obj = new |
| | | { |
| | | x = taskPosition.PutCenterPositionX - containerSize.Length / 2, |
| | | y = taskPosition.PutCenterPositionY - containerSize.Width / 2, |
| | | z = taskPosition.PutCenterPositionZ, |
| | | length, |
| | | width, |
| | | height, |
| | | }; |
| | | if (i == 0) |
| | | Thread.Sleep(5000); |
| | | _webSocketServer.PublishAllClientPayload(obj.Serialize()); |
| | | Thread.Sleep(500); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public TaskPosition GetTakePutPosition(int length, int width, int height, ContainerSize containerSize, List<PlacedBlock> placedBlocks) |
| | | { |
| | | try |
| | | { |
| | | PlaceBlockService placeBlockService = new PlaceBlockService(containerSize, placedBlocks); |
| | | |
| | | Point3D? point3D = placeBlockService.PlaceBlock(length, width, height); |
| | | if (point3D == null) |
| | | { |
| | | throw new Exception("æ¾è´§ä½ç½®å·²æ»¡"); |
| | | } |
| | | |
| | | //æ¾è´§ä½ç½®æ¿æä¸å¿ç¹ |
| | | Point3D putCenter = new Point3D(point3D.Value.X + length / 2, point3D.Value.Y + width / 2, point3D.Value.Z + height / 2); |
| | | |
| | | //åè´§ä½ç½®æ¿æä¸å¿ç¹ |
| | | Point3D takeCenter = new Point3D(length / 2, width / 2, height / 2); |
| | | |
| | | //å¸çé¿530 é´é660 æå¤§920 å¸ç宽130 |
| | | |
| | | int positionR = 1; |
| | | |
| | | int takePositionX = 0; |
| | | int takePositionY = 0; |
| | | int takePositionZ = 0; |
| | | int putPositionX = 0; |
| | | int putPositionY = 0; |
| | | int putPositionZ = 0; |
| | | |
| | | //1.妿é¿åº¦å¤§äº920ï¼å®½åº¦å¤§äºçäº300ï¼åå¯ä»¥ä½¿ç¨åå¸ç横åå¸å |
| | | if (length > 920 && width >= 300) |
| | | { |
| | | // |
| | | Point3D deviceCenter = new Point3D(530 / 2, 920 / 2, 0); |
| | | |
| | | positionR = 1; |
| | | takePositionX = takeCenter.Y - deviceCenter.X; |
| | | takePositionY = takeCenter.X - deviceCenter.Y; |
| | | takePositionZ = 10; |
| | | |
| | | putPositionX = putCenter.Y - deviceCenter.X; |
| | | putPositionY = putCenter.X - deviceCenter.Y; |
| | | putPositionZ = point3D.Value.Z; // putCenter.Z /*+ 10*/; |
| | | } |
| | | else |
| | | { |
| | | positionR = 0; |
| | | Point3D deviceCenter = new Point3D(130 / 2, 530 / 2, 0); |
| | | takePositionX = takeCenter.Y - deviceCenter.X; |
| | | takePositionY = takeCenter.X - deviceCenter.Y; |
| | | takePositionZ = 10; |
| | | |
| | | putPositionX = putCenter.Y - deviceCenter.X; |
| | | putPositionY = putCenter.X - deviceCenter.Y; |
| | | putPositionZ = point3D.Value.Z; //putCenter.Z /*+ 10*/; |
| | | } |
| | | |
| | | TaskPosition taskPosition = new TaskPosition() |
| | | { |
| | | PositionR = positionR, |
| | | TakePositionX = takePositionX, |
| | | TakePositionY = takePositionY, |
| | | TakePositionZ = takePositionZ, |
| | | PutPositionX = putPositionX, |
| | | PutPositionY = putPositionY, |
| | | PutPositionZ = putPositionZ, |
| | | TakeCenterPositionX = takeCenter.X, |
| | | TakeCenterPositionY = takeCenter.Y, |
| | | TakeCenterPositionZ = takeCenter.Z, |
| | | PutCenterPositionX = putCenter.X, |
| | | PutCenterPositionY = putCenter.Y, |
| | | PutCenterPositionZ = putCenter.Z, |
| | | PositionX = point3D.Value.X, |
| | | PositionY = point3D.Value.Y, |
| | | PositionZ = point3D.Value.Z |
| | | }; |
| | | |
| | | return taskPosition; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | ContainerSize containerSize = new ContainerSize(putContainer.ContainerLength, putContainer.ContainerWidth, putContainer.ContainerHeight); |
| | | List<Dt_ContainerItem> containerItems = _containerItemRepository.QueryData(x => x.ContainerId == putContainer.Id); |
| | | |
| | | List<PlacedBlock> placedBlocks = containerItems.Select(x => new PlacedBlock(new Point3D(x.ItemPositionX, x.ItemPositionY, x.ItemPositionZ), x.ItemLength, x.ItemWidth, x.ItemHeight)).ToList(); |
| | | List<PlacedBlock> placedBlocks = containerItems.Select(x => new PlacedBlock(new Point3D(x.ItemRelaPositionX, x.ItemRelaPositionY, x.ItemRelaPositionZ), x.ItemLength, x.ItemWidth, x.ItemHeight)).ToList(); |
| | | |
| | | |
| | | TaskPosition taskPosition = GetTakePutPosition(length, width, height, containerSize, placedBlocks); |
| | | TaskPosition? taskPosition = _containerService.GetTaskPosition(length, width, height, containerSize, placedBlocks); |
| | | if (taskPosition == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°åéæ¾ç½®ä½ç½®"); |
| | | } |
| | | |
| | | object obj = new |
| | | { |
| | |
| | | ItemPositionX = taskPosition.PutPositionX, |
| | | ItemPositionY = taskPosition.PutPositionY, |
| | | ItemPositionZ = taskPosition.PutPositionZ, |
| | | ItemRelaPositionX = taskPosition.PositionX, |
| | | ItemRelaPositionY = taskPosition.PositionY, |
| | | ItemRelaPositionZ = taskPosition.PositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = code |
| | | }; |
| | | |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = 1, |
| | | PalletCode = code, |
| | | DeviceCode = deviceCode, |
| | | DeviceCode = putContainer.DeviceCode, |
| | | TaskState = (int)TaskStatusEnum.Gantry_New, |
| | | TaskType = 0, |
| | | SourceAddress = $"{takePosition}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}", |
| | | TargetAddress = $"{putPosition}*{taskPosition.PutPositionX}*{taskPosition.PutPositionX}*{taskPosition.PutPositionZ}*{taskPosition.PositionR}", |
| | | CurrentAddress = $"{takePosition}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}", |
| | | NextAddress = $"{putPosition}*{taskPosition.PutPositionX}*{taskPosition.PutPositionX}*{taskPosition.PutPositionZ}*{taskPosition.PositionR}", |
| | | SourceAddress = "", |
| | | TargetAddress = $"{takeContainer.ContainerNo}", |
| | | CurrentAddress = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}", |
| | | NextAddress = $"{putContainer.ContainerCode}*{taskPosition.PutPositionX}*{taskPosition.PutPositionY}*{taskPosition.PutPositionZ}*{taskPosition.PositionR}", |
| | | ItemInfo = $"{length}*{width}*{height}", |
| | | Grade = 0, |
| | | }; |
| | | |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public Dt_Task GenerateTask(OrderInfo orderInfo) |
| | | { |
| | | try |
| | | { |
| | | int length = Convert.ToInt32(orderInfo.Length); |
| | | int width = Convert.ToInt32(orderInfo.Width); |
| | | int height = Convert.ToInt32(orderInfo.Thickness); |
| | | |
| | | TaskPosition? taskPosition = _containerService.GetPosition(orderInfo.OrderNo, length, width, height); |
| | | if (taskPosition != null) |
| | | { |
| | | int lengthThreshold = AppSettings.Get("LengthThreshold").ObjToInt(); |
| | | if (taskPosition.TakePositionY > lengthThreshold) |
| | | { |
| | | throw new Exception("10002,é¿åº¦è¶
åºéå¶"); |
| | | } |
| | | |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerCode == taskPosition.PutPosition); |
| | | if (putContainer == null) |
| | | { |
| | | //todo |
| | | throw new Exception("æªæ¾å°æ¾è´§ä½ç½®"); |
| | | } |
| | | |
| | | Dt_Container? takeContainer = GetTakePosition(putContainer.DeviceCode); |
| | | if (takeContainer == null) |
| | | { |
| | | throw new Exception("æªæ¾å°åè´§ä½ç½®"); |
| | | } |
| | | |
| | | Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(x => x.OrderNo == orderInfo.OrderNo && x.ContainerCode == putContainer.ContainerCode); |
| | | |
| | | bool isAdd = false; |
| | | bool isUpdate = false; |
| | | if (orderContainer == null) |
| | | { |
| | | orderContainer = new Dt_OrderContainer() |
| | | { |
| | | OrderId = orderInfo.OrderHeadId, |
| | | ContainerCode = putContainer.ContainerCode, |
| | | ContainerId = putContainer.Id, |
| | | OrderNo = orderInfo.OrderNo, |
| | | }; |
| | | |
| | | if (length > lengthThreshold) |
| | | { |
| | | orderContainer.MaxLength = putContainer.ContainerLength; |
| | | } |
| | | else |
| | | { |
| | | orderContainer.MaxLength = lengthThreshold; |
| | | } |
| | | isAdd = true; |
| | | } |
| | | else |
| | | { |
| | | if (length < lengthThreshold) |
| | | { |
| | | isUpdate = true; |
| | | orderContainer.MaxLength = lengthThreshold; |
| | | } |
| | | } |
| | | |
| | | Dt_ContainerItem dt_ContainerItem = new Dt_ContainerItem() |
| | | { |
| | | ContainerId = putContainer.Id, |
| | | ItemCode = orderInfo.Barcode, |
| | | ItemLength = length, |
| | | ItemWidth = width, |
| | | ItemHeight = height, |
| | | ItemPositionX = taskPosition.PositionX, |
| | | ItemPositionY = taskPosition.PositionY, |
| | | ItemPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PositionX, |
| | | ItemRelaPositionY = taskPosition.PositionY, |
| | | ItemRelaPositionZ = taskPosition.PositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = orderInfo.Barcode |
| | | }; |
| | | |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | PalletCode = orderInfo.Barcode, |
| | | DeviceCode = putContainer.DeviceCode, |
| | | TaskState = (int)TaskStatusEnum.Gantry_Wait, |
| | | TaskType = 0, |
| | | SourceAddress = "", |
| | | TargetAddress = $"{takeContainer.ContainerNo}", |
| | | CurrentAddress = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}", |
| | | NextAddress = $"{putContainer.ContainerCode}*{taskPosition.PutPositionX}*{taskPosition.PutPositionY}*{taskPosition.PutPositionZ}*{taskPosition.PositionR}", |
| | | ItemInfo = $"{length}*{width}*{height}", |
| | | Grade = 0, |
| | | }; |
| | | putContainer.ContainerStatus = ContainerStatusEnum.NonEmpty.ObjToInt(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _containerRepository.UpdateData(putContainer); |
| | | _containerItemRepository.AddData(dt_ContainerItem); |
| | | if (isAdd) |
| | | { |
| | | _orderContainerRepository.AddData(orderContainer); |
| | | } |
| | | else if (isUpdate) |
| | | { |
| | | _orderContainerRepository.UpdateData(orderContainer); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return dt_Task; |
| | | } |
| | | throw new Exception($"æ 坿¾ç½®ä½ç½®"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public Dt_Container? GetTakePosition(string deviceCode) |
| | | { |
| | | Dictionary<string, OrderByType> orderby = new Dictionary<string, OrderByType>() { { nameof(Dt_Container.ContainerSort), OrderByType.Asc } }; |
| | | List<Dt_Container> containers = _containerRepository.QueryData(x => x.ContainerType == ContainerTypeEnum.TakeContainer.ObjToInt() && x.DeviceCode == deviceCode && x.ContainerEnable, orderby); |
| | | |
| | | try |
| | | { |
| | | if (containers == null || containers.Count == 0) |
| | | { |
| | | throw new Exception($"æªæ¾å°å¯¹åºçåè´§ä½ç½®,设å¤ç¼å·:{deviceCode}"); |
| | | } |
| | | |
| | | Dictionary<string, OrderByType> taskOrderby = new Dictionary<string, OrderByType>() { { nameof(Dt_Task.TaskNum), OrderByType.Desc } }; |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.DeviceCode == deviceCode, taskOrderby); |
| | | if (task != null) |
| | | { |
| | | string? sourceCode = task.SourceAddress.Split("*").FirstOrDefault(); |
| | | if (!string.IsNullOrEmpty(sourceCode)) |
| | | { |
| | | Dt_Container? container = containers.FirstOrDefault(x => x.ContainerCode == sourceCode); |
| | | if (container != null) |
| | | { |
| | | int index = containers.IndexOf(container); |
| | | |
| | | if (index + 1 < containers.Count) |
| | | { |
| | | return containers[index + 1]; |
| | | } |
| | | else |
| | | { |
| | | return containers.FirstOrDefault(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | return containers.FirstOrDefault(); |
| | | } |
| | | |
| | | public void TaskComplete(Dt_Task task) |
| | | { |
| | | try |
| | | { |
| | | task.TaskState = TaskStatusEnum.Gantry_Completed.ObjToInt(); |
| | | |
| | | |
| | | OrderDetails orderDetails = _orderDetailsRepository.QueryFirst(x => x.Orderdetails_outid == task.PalletCode); |
| | | if (orderDetails != null) |
| | | { |
| | | orderDetails.Orderdetails_status = PalletingStatusEnmu.PalletingSuccess.ObjToInt(); |
| | | |
| | | |
| | | Orderrows orderrows = _orderrowsRepository.QueryFirst(x => x.id == orderDetails.Orderrowsid); |
| | | if (orderrows != null) |
| | | { |
| | | orderrows.Orderrows_PalletNum = orderrows.Orderrows_PalletNum ?? 0 + 1; |
| | | |
| | | |
| | | Dt_Container container = _containerRepository.QueryFirst(x => task.NextAddress.Contains(x.ContainerCode)); |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User?.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _orderDetailsRepository.UpdateData(orderDetails); |
| | | _orderrowsRepository.UpdateData(orderrows); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | List<object> list = new List<object>(); |
| | | |
| | | List<OrderDetails> totalDetails = _orderDetailsRepository.QueryData(x => x.Orderrowsid == orderDetails.Orderrowsid); |
| | | |
| | | List<OrderDetails> details = totalDetails.Where(x => x.Orderrowsid == orderDetails.Orderrowsid && x.Orderdetails_status == PalletingStatusEnmu.PalletingSuccess.ObjToInt()).ToList(); |
| | | foreach (var item in details) |
| | | { |
| | | object obj = new |
| | | { |
| | | orderCode = orderrows.Orderrows_orderid, |
| | | cusName = orderrows.Orderrows_customer, |
| | | orderName = orderrows.Orderrows_name, |
| | | batch = orderrows.Orderrows_batchid, |
| | | productName = "" |
| | | }; |
| | | list.Add(obj); |
| | | } |
| | | |
| | | object data = new |
| | | { |
| | | stationCode = task.NextAddress.Split("*").FirstOrDefault(), |
| | | orderTotalNum = totalDetails.Count, |
| | | sortedNum = details.Count, |
| | | unsortedNum = totalDetails.Count - details.Count, |
| | | orderData = list |
| | | }; |
| | | List<WebSocketSession> webSocketSessions2 = _webSocketServer.OnlineSessions.ToList(); |
| | | List<WebSocketSession> webSocketSessions = _webSocketServer.OnlineSessions.Where(x => x.Url.Contains(task.DeviceCode ?? "")).ToList(); |
| | | foreach (var item in webSocketSessions) |
| | | { |
| | | _webSocketServer.SendClientPayload(item, data.Serialize()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | } |
| | | } |
| | | } |
| | | } |