| | |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using HslCommunication.WebSocket; |
| | | using SqlSugar; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | |
| | | return WebResponseContent.Instance.Error("æªæ¾å°è®¢åæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | |
| | | |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()); |
| | | if (putContainer == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æ¾è´§ä½ç½®ä¸åå¨"); |
| | | } |
| | | |
| | | |
| | | List<PlacedBlock> placedBlocks = new List<PlacedBlock>(); |
| | | |
| | | string putPosition = ""; |
| | | |
| | | for (int i = 0; i < orderDetails.Count; i++) |
| | | { |
| | |
| | | int width = Convert.ToInt32(orderDetails[i].Orderdetails_width); |
| | | int height = Convert.ToInt32(orderDetails[i].Orderdetails_thickness); |
| | | |
| | | if (length < 300 || width < 50) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | OrderInfo orderInfo = _orderDetailsService.GetOrderInfoByBarcode(orderDetails[i].Orderdetails_outid); |
| | | Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(x => x.OrderNo == orderInfo.OrderNo && x.ContainerCode == putContainer.ContainerCode); |
| | | |
| | | ContainerSize containerSize = new ContainerSize(putContainer.ContainerLength, putContainer.ContainerWidth, putContainer.ContainerHeight); |
| | | var (flag, taskPosition, message) = _containerService.GetPosition(orderInfo.OrderHeadId, orderInfo.OrderNo, length, width, height); |
| | | if (flag && taskPosition != null) |
| | | { |
| | | if (string.IsNullOrEmpty(putPosition)) |
| | | { |
| | | putPosition = taskPosition.PutPosition; |
| | | } |
| | | |
| | | int lengthThreshold = AppSettings.Get("LengthThreshold").ObjToInt(); |
| | | if (putPosition != taskPosition.PutPosition) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(x => x.OrderNo == orderInfo.OrderNo && x.ContainerCode == taskPosition.PutPosition); |
| | | |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerCode == taskPosition.PutPosition); |
| | | if (putContainer == null) |
| | | { |
| | | //todo |
| | | throw new Exception("æªæ¾å°æ¾è´§ä½ç½®"); |
| | | } |
| | | |
| | | bool isAdd = false; |
| | | bool isUpdate = false; |
| | | if (orderContainer == null) |
| | | { |
| | | orderContainer = new Dt_OrderContainer() |
| | |
| | | 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; |
| | | } |
| | | containerSize = new ContainerSize(orderContainer.MaxLength, putContainer.ContainerWidth, putContainer.ContainerHeight); |
| | | } |
| | | |
| | | |
| | | |
| | | 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, |
| | |
| | | ItemPositionX = taskPosition.PositionX, |
| | | ItemPositionY = taskPosition.PositionY, |
| | | ItemPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PositionX, |
| | | ItemRelaPositionY = taskPosition.PositionY, |
| | | ItemRelaPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = orderInfo.Barcode |
| | | }; |
| | |
| | | { |
| | | _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); |
| | | PlacedBlock placedBlock = new PlacedBlock(new Point3D(taskPosition.PositionX, taskPosition.PositionY, taskPosition.PositionZ), length > width ? length : width, width > length ? length : width, height); |
| | | placedBlocks.Add(placedBlock); |
| | | |
| | | object obj = new |
| | | { |
| | | x = taskPosition.PutCenterPositionX - containerSize.Length / 2, |
| | | y = taskPosition.PutCenterPositionY - containerSize.Width / 2, |
| | | x = taskPosition.PutCenterPositionX - putContainer.ContainerLength / 2, |
| | | y = taskPosition.PutCenterPositionY - putContainer.ContainerWidth / 2, |
| | | z = taskPosition.PutCenterPositionZ, |
| | | length, |
| | | width, |
| | | height, |
| | | }; |
| | | if (i == 0) |
| | | Thread.Sleep(5000); |
| | | _webSocketServer.PublishAllClientPayload(obj.Serialize()); |
| | | Thread.Sleep(500); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | return WebResponseContent.Instance.Error("åè´§ä½ç½®ä¸åå¨"); |
| | | } |
| | | |
| | | List<Dt_Container> containers = _containerRepository.QueryData(x => x.DeviceCode == deviceCode && x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()); |
| | | |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerCode == putPosition && x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()); |
| | | if (putContainer == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æ¾è´§ä½ç½®ä¸åå¨"); |
| | | } |
| | | |
| | | int edge = 0; |
| | | if (putContainer.ContainerNo == containers.Min(x => x.ContainerNo)) |
| | | { |
| | | edge = 1; |
| | | } |
| | | |
| | | 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.ItemRelaPositionX, x.ItemRelaPositionY, x.ItemRelaPositionZ), x.ItemLength, x.ItemWidth, x.ItemHeight)).ToList(); |
| | | List<PlacedBlock> placedBlocks = containerItems.Select(x => new PlacedBlock(new Point3D(x.ItemPositionX, x.ItemPositionY, x.ItemPositionZ), x.ItemLength > x.ItemLength ? x.ItemLength : x.ItemWidth, x.ItemLength > x.ItemLength ? x.ItemWidth : x.ItemLength, x.ItemHeight)).ToList(); |
| | | |
| | | |
| | | TaskPosition? taskPosition = _containerService.GetTaskPosition(length, width, height, containerSize, placedBlocks); |
| | | TaskPosition? taskPosition = _containerService.GetTaskPosition(length, width, height, containerSize, placedBlocks, edge); |
| | | if (taskPosition == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°åéæ¾ç½®ä½ç½®"); |
| | |
| | | ItemLength = length, |
| | | ItemWidth = width, |
| | | ItemHeight = height, |
| | | ItemPositionX = taskPosition.PutPositionX, |
| | | ItemPositionY = taskPosition.PutPositionY, |
| | | ItemPositionZ = taskPosition.PutPositionZ, |
| | | ItemRelaPositionX = taskPosition.PositionX, |
| | | ItemRelaPositionY = taskPosition.PositionY, |
| | | ItemRelaPositionZ = taskPosition.PositionZ, |
| | | ItemPositionX = taskPosition.PositionX, |
| | | ItemPositionY = taskPosition.PositionY, |
| | | ItemPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = code |
| | | }; |
| | |
| | | } |
| | | } |
| | | |
| | | public Dt_Task GenerateTask(OrderInfo orderInfo) |
| | | public (bool, Dt_Task?, string) GenerateTask(OrderInfo orderInfo) |
| | | { |
| | | try |
| | | { |
| | |
| | | int width = Convert.ToInt32(orderInfo.Width); |
| | | int height = Convert.ToInt32(orderInfo.Thickness); |
| | | |
| | | TaskPosition? taskPosition = _containerService.GetPosition(orderInfo.OrderNo, length, width, height); |
| | | if (taskPosition != null) |
| | | var (flag, taskPosition, message) = _containerService.GetPosition(orderInfo.OrderHeadId, orderInfo.OrderNo, length, width, height); |
| | | if (flag && 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("æªæ¾å°æ¾è´§ä½ç½®"); |
| | | return (false, null, "æªæ¾å°æ¾è´§ä½ç½®"); |
| | | } |
| | | |
| | | Dt_Container? takeContainer = GetTakePosition(putContainer.DeviceCode); |
| | | if (takeContainer == null) |
| | | { |
| | | throw new Exception("æªæ¾å°åè´§ä½ç½®"); |
| | | return (false, null, "æªæ¾å°åè´§ä½ç½®"); |
| | | } |
| | | |
| | | Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(x => x.OrderNo == orderInfo.OrderNo && x.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() |
| | |
| | | ItemPositionX = taskPosition.PositionX, |
| | | ItemPositionY = taskPosition.PositionY, |
| | | ItemPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PositionX, |
| | | ItemRelaPositionY = taskPosition.PositionY, |
| | | ItemRelaPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = orderInfo.Barcode |
| | | ItemName = orderInfo.Barcode, |
| | | Remark = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}" |
| | | }; |
| | | |
| | | Dt_Task dt_Task = new Dt_Task() |
| | |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return dt_Task; |
| | | return (true, dt_Task, ""); |
| | | } |
| | | throw new Exception($"æ 坿¾ç½®ä½ç½®"); |
| | | else |
| | | { |
| | | return (false, null, $"æ 坿¾ç½®ä½ç½®,{orderInfo.Serialize()}"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | return (false, null, $"é误,{ex.ExceptionToString()}"); |
| | | } |
| | | } |
| | | |
| | |
| | | return containers.FirstOrDefault(); |
| | | } |
| | | |
| | | public void TaskComplete(Dt_Task task) |
| | | public WebResponseContent TaskComplete(Dt_Task task) |
| | | { |
| | | try |
| | | { |
| | | task.TaskState = TaskStatusEnum.Gantry_Completed.ObjToInt(); |
| | | |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | 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) |
| | | try |
| | | { |
| | | object obj = new |
| | | List<string> containerItemCodes = _containerItemRepository.QueryData(x => x.ContainerId == container.Id).Select(x => x.ItemCode).ToList(); |
| | | |
| | | List<OrderDetails> totalDetails = _orderDetailsRepository.QueryData(x => x.Orderrowsid == orderrows.id); |
| | | List<OrderDetails> details = totalDetails.Where(x => x.Orderrowsid == orderrows.id && x.Orderdetails_status == PalletingStatusEnmu.PalletingSuccess.ObjToInt() && containerItemCodes.Contains(x.Orderdetails_outid)).ToList(); |
| | | |
| | | int sortedNum = totalDetails.Where(x => x.Orderrowsid == orderrows.id && x.Orderdetails_status == PalletingStatusEnmu.PalletingSuccess.ObjToInt()).Count(); |
| | | object data = new object(); |
| | | if (totalDetails.Count <= sortedNum) |
| | | { |
| | | data = new |
| | | { |
| | | stationCode = task.NextAddress.Split("*").FirstOrDefault(), |
| | | release = 1, |
| | | data = new |
| | | { |
| | | stationCode = task.NextAddress.Split("*").FirstOrDefault(), |
| | | orderTotalNum = totalDetails.Count, |
| | | sortedNum = sortedNum, |
| | | unsortedNum = totalDetails.Count - sortedNum, |
| | | stationSortedNum = details.Count, |
| | | orderId = orderrows.id, |
| | | orderData = new |
| | | { |
| | | orderCode = orderrows.Orderrows_orderid, |
| | | cusName = orderrows.Orderrows_customer, |
| | | orderName = orderrows.Orderrows_name, |
| | | batch = orderrows.Orderrows_batchid, |
| | | productName = "" |
| | | }; |
| | | list.Add(obj); |
| | | productName = "", |
| | | } |
| | | |
| | | object data = new |
| | | } |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | data = new |
| | | { |
| | | stationCode = task.NextAddress.Split("*").FirstOrDefault(), |
| | | release = 0, |
| | | data = new |
| | | { |
| | | stationCode = task.NextAddress.Split("*").FirstOrDefault(), |
| | | orderTotalNum = totalDetails.Count, |
| | | sortedNum = details.Count, |
| | | unsortedNum = totalDetails.Count - details.Count, |
| | | orderData = list |
| | | sortedNum = sortedNum, |
| | | unsortedNum = totalDetails.Count - sortedNum, |
| | | stationSortedNum = details.Count, |
| | | orderId = orderrows.id, |
| | | orderData = new |
| | | { |
| | | orderCode = orderrows.Orderrows_orderid, |
| | | cusName = orderrows.Orderrows_customer, |
| | | orderName = orderrows.Orderrows_name, |
| | | batch = orderrows.Orderrows_batchid, |
| | | productName = "", |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | 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) |
| | | { |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | BaseDal.DeleteAndMoveIntoHty(task, App.User?.UserId > 0 ? OperateTypeEnum.äººå·¥å®æ : OperateTypeEnum.èªå¨å®æ); |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |