| | |
| | | *----------------------------------------------------------------*/ |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using AutoMapper; |
| | | using Magicodes.ExporterAndImporter.Core; |
| | | using Microsoft.AspNetCore.Mvc.RazorPages; |
| | | using NetTaste; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Diagnostics; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Linq; |
| | | using System.Linq.Expressions; |
| | | using System.Reflection; |
| | | using System.Reflection.Metadata; |
| | | using System.Security.Policy; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Xml.Linq; |
| | | using WIDESEA_Common.Log; |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using HslCommunication.WebSocket; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Information; |
| | | using SqlSugar; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.Utilities; |
| | | using WIDESEAWCS_DTO.Enum; |
| | | 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.Models; |
| | | using WIDESEAWCS_QuartzJob.Repository; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using static Dm.net.buffer.ByteArrayBuffer; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | | /// <summary> |
| | | /// 任塿å¡ç±»ï¼æä¾ä»»å¡ç¸å
³çä¸å¡é»è¾æä½ |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// 主è¦åè½å
æ¬ï¼ <br/> |
| | | /// 1. æ¥è¯¢é¨æ¶è®¾å¤æªæ§è¡ä»»å¡ <br/> |
| | | /// 2. æ§è¡è®¢ååæ¾ç½®æµè¯ <br/> |
| | | /// 3. å建å管çä»»å¡ <br/> |
| | | /// 4. çæåéæ°çæä»»å¡ <br/> |
| | | /// 5. å¤çå¼å¸¸ä»»å¡ <br/> |
| | | /// 6. ä»»å¡å®æå¤ç <br/> |
| | | /// ä¾èµä»å¨å±è¿è¡æ°æ®è®¿é®ï¼éè¿å·¥ä½åå
管çäºå¡ <br/> |
| | | /// 使ç¨WebSocketè¿è¡å®æ¶éç¥ï¼å¹¶å
å«å®æ´çå¼å¸¸å¤çæºå¶ |
| | | /// </remarks> |
| | | public class TaskService : ServiceBase<Dt_Task, ITaskRepository>, ITaskService |
| | | { |
| | | private readonly IMapper _mapper; |
| | | private readonly IContainerRepository _containerRepository; |
| | | private readonly IContainerItemRepository _containerItemRepository; |
| | | private readonly IDeviceInfoRepository _deviceInfoRepository; |
| | | /// <summary> |
| | | /// å·¥ä½åå
ç®¡çæ¥å£å®ä¾ï¼ç¨äºç®¡çæ°æ®åºäºå¡åå·¥ä½åå
|
| | | /// </summary> |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | |
| | | public TaskService(ITaskRepository BaseDal, IMapper mapper, IContainerRepository containerRepository, IContainerItemRepository containerItemRepository, IDeviceInfoRepository deviceInfoRepository) : base(BaseDal) |
| | | /// <summary> |
| | | /// ç¨äºå¯¹è±¡æ å°çæ å°å¨å®ä¾ |
| | | /// </summary> |
| | | private readonly IMapper _mapper; |
| | | |
| | | /// <summary> |
| | | /// 容å¨ä»å¨æ¥å£å®ä¾ï¼ç¨äºå®¹å¨ç¸å
³æ°æ®æä½ |
| | | /// </summary> |
| | | private readonly IContainerRepository _containerRepository; |
| | | |
| | | /// <summary> |
| | | /// 容å¨ç©åä»å¨æ¥å£å®ä¾ï¼åªè¯»ï¼ |
| | | /// </summary> |
| | | private readonly IContainerItemRepository _containerItemRepository; |
| | | |
| | | /// <summary> |
| | | /// WebSocketæå¡å¨å®ä¾ï¼ç¨äºå¤çWebSocketè¿æ¥ |
| | | /// </summary> |
| | | private readonly WebSocketServer _webSocketServer; |
| | | |
| | | /// <summary> |
| | | /// 订å详æ
ä»å¨æ¥å£å®ä¾ï¼åªè¯»ï¼ |
| | | /// </summary> |
| | | private readonly IOrderDetailsRepository _orderDetailsRepository; |
| | | |
| | | /// <summary> |
| | | /// 容卿塿¥å£å®ä¾ï¼ç¨äºç®¡çä¾èµæ³¨å
¥å®¹å¨ç¸å
³æä½ |
| | | /// </summary> |
| | | private readonly IContainerService _containerService; |
| | | |
| | | /// <summary> |
| | | /// 订åæç»æå¡æ¥å£ |
| | | /// </summary> |
| | | private readonly IOrderDetailsService _orderDetailsService; |
| | | |
| | | /// <summary> |
| | | /// 订åè¡ä»å¨æ¥å£å®ä¾ï¼ç¨äºæä½è®¢åè¡æ°æ® |
| | | /// </summary> |
| | | private readonly IOrderrowsRepository _orderrowsRepository; |
| | | |
| | | /// <summary> |
| | | /// 订å容å¨ä»å¨æ¥å£å®ä¾ï¼ç¨äºæä½è®¢å容å¨ç¸å
³æ°æ® |
| | | /// </summary> |
| | | private readonly IOrderContainerRepository _orderContainerRepository; |
| | | |
| | | 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; |
| | | _deviceInfoRepository = deviceInfoRepository; |
| | | _webSocketServer = webSocketServer; |
| | | _orderDetailsRepository = orderDetailsRepository; |
| | | _containerService = containerService; |
| | | _orderDetailsService = orderDetailsService; |
| | | _orderrowsRepository = orderrowsRepository; |
| | | _orderContainerRepository = orderContainerRepository; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢æå®é¨æ¶è®¾å¤æªæ§è¡çä»»å¡ |
| | | /// </summary> |
| | | /// <param name="gantryDeviceNo">鍿¶è®¾å¤ç¼å·</param> |
| | | /// <returns>æªæ§è¡ç任塿°æ®ï¼è¥ä¸åå¨åè¿ånull</returns> |
| | | public Dt_Task? QueryAGantryUnExecuteTask(string gantryDeviceNo) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskState == (int)TaskStatusEnum.Gantry_New && x.DeviceCode == gantryDeviceNo); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ§è¡è®¢ååæ¾ç½®æµè¯ï¼æ ¹æ®è®¢åè¡IDè·å订åæç»å¹¶è®¡ç®æ¾ç½®ä½ç½® |
| | | /// </summary> |
| | | /// <param name="orderRowId">订åè¡ID</param> |
| | | /// <returns>å
嫿¾ç½®åä¿¡æ¯çWebååºå
容ãæåæ¶è¿åæ¾ç½®åå表ï¼å¤±è´¥æ¶è¿åé误信æ¯</returns> |
| | | /// <remarks> |
| | | /// 1. éè¿è®¢åè¡IDæ¥è¯¢è®¢åæç»æ°æ® <br/> |
| | | /// 2. 对æ¯ä¸ªææè®¢åæç»è®¡ç®åéçæ¾ç½®ä½ç½® <br/> |
| | | /// 3. å建容å¨é¡¹åä»»å¡è®°å½ <br/> |
| | | /// 4. éè¿WebSocketå叿¾ç½®ä½ç½®ä¿¡æ¯ <br/> |
| | | /// 5. è¿åæææåæ¾ç½®çåä¿¡æ¯ |
| | | /// </remarks> |
| | | public WebResponseContent PlaceBlockTest(int orderRowId) |
| | | { |
| | | try |
| | | { |
| | | List<OrderDetails> orderDetails = _orderDetailsRepository.QueryData(x => x.Orderrowsid == orderRowId); |
| | | if (orderDetails == null || orderDetails.Count == 0) |
| | | { |
| | | return WebResponseContent.Instance.Error("æªæ¾å°è®¢åæç»ä¿¡æ¯"); |
| | | } |
| | | |
| | | List<PlacedBlock> placedBlocks = new List<PlacedBlock>(); |
| | | |
| | | string putPosition = ""; |
| | | |
| | | for (int i = 0; i < orderDetails.Count; i++) |
| | | { |
| | | try |
| | | { |
| | | lock (placedBlocks) |
| | | { |
| | | int length = Convert.ToInt32(orderDetails[i].Orderdetails_length); |
| | | int width = Convert.ToInt32(orderDetails[i].Orderdetails_width); |
| | | int height = Convert.ToInt32(orderDetails[i].Orderdetails_thickness); |
| | | |
| | | OrderInfo orderInfo = _orderDetailsService.GetOrderInfoByBarcode(orderDetails[i].Orderdetails_outid); |
| | | |
| | | var (flag, taskPosition, message) = _containerService.GetPosition(orderInfo.OrderHeadId, orderInfo.OrderNo, length, width, height); |
| | | if (flag && taskPosition != null) |
| | | { |
| | | if (string.IsNullOrEmpty(putPosition)) |
| | | { |
| | | putPosition = taskPosition.PutPosition; |
| | | } |
| | | |
| | | 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; |
| | | if (orderContainer == null) |
| | | { |
| | | orderContainer = new Dt_OrderContainer() |
| | | { |
| | | OrderId = orderInfo.OrderHeadId, |
| | | ContainerCode = putContainer.ContainerCode, |
| | | ContainerId = putContainer.Id, |
| | | OrderNo = orderInfo.OrderNo, |
| | | }; |
| | | int containerLength = putContainer.ContainerLength; |
| | | int containerWidth = putContainer.ContainerWidth; |
| | | int maxValue = Math.Max(length, width); |
| | | int minValue = Math.Min(length, width); |
| | | if (minValue > putContainer.ContainerWidth) |
| | | { |
| | | containerLength = maxValue; |
| | | containerWidth = minValue; |
| | | } |
| | | |
| | | orderContainer.MaxLength = containerLength; |
| | | orderContainer.MaxWidth = containerWidth; |
| | | isAdd = true; |
| | | } |
| | | |
| | | 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.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | 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); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | PlacedBlock placedBlock = new PlacedBlock(new Point3D(taskPosition.PositionX, taskPosition.PositionY, taskPosition.PositionZ), length > width ? length : width, width > length ? length : width, height); |
| | | placedBlocks.Add(placedBlock); |
| | | |
| | | Thread.Sleep(1000); |
| | | object obj = new |
| | | { |
| | | x = taskPosition.PutCenterPositionX - putContainer.ContainerLength / 2, |
| | | y = taskPosition.PutCenterPositionY - putContainer.ContainerWidth / 2, |
| | | z = taskPosition.PutPositionZ, |
| | | length = length > width ? length : width, |
| | | width = width > length ? length : width, |
| | | height, |
| | | }; |
| | | _webSocketServer.PublishAllClientPayload(obj.Serialize()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | } |
| | | } |
| | | return WebResponseContent.Instance.OK(data: placedBlocks); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建任å¡å¹¶è®¡ç®ç©åæ¾ç½®ä½ç½® |
| | | /// </summary> |
| | | /// <param name="takePosition">åè´§ä½ç½®ç¼ç </param> |
| | | /// <param name="putPosition">æ¾è´§ä½ç½®ç¼ç </param> |
| | | /// <param name="deviceCode">设å¤ç¼ç </param> |
| | | /// <param name="length">ç©åé¿åº¦</param> |
| | | /// <param name="width">ç©å宽度</param> |
| | | /// <param name="height">ç©åé«åº¦</param> |
| | | /// <returns>å
嫿ä½ç»æçWebååºå
容</returns> |
| | | /// <remarks> |
| | | /// 1. éªè¯åè´§/æ¾è´§ä½ç½®æ¯å¦åå¨ <br/> |
| | | /// 2. 计ç®ç©åå¨å®¹å¨ä¸çæä½³æ¾ç½®ä½ç½® <br/> |
| | | /// 3. å建容å¨ç©åè®°å½åä»»å¡è®°å½ <br/> |
| | | /// 4. éè¿WebSocketéç¥å®¢æ·ç«¯ |
| | | /// </remarks> |
| | | public WebResponseContent CreateTask(string takePosition, string putPosition, string deviceCode, int length, int width, int height) |
| | | { |
| | | try |
| | |
| | | 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.ItemPositionX, x.ItemPositionY, x.ItemPositionZ), 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(); |
| | | |
| | | PlaceBlockService placeBlockService = new PlaceBlockService(containerSize, placedBlocks); |
| | | |
| | | Point3D? point3D = placeBlockService.PlaceBlock(length, width, height); |
| | | if (point3D == null) |
| | | TaskPosition? taskPosition = _containerService.GetTaskPosition(length, width, height, containerSize, placedBlocks, edge); |
| | | if (taskPosition == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("æ¾è´§ä½ç½®å·²æ»¡"); |
| | | return WebResponseContent.Instance.Error("æªæ¾å°åéæ¾ç½®ä½ç½®"); |
| | | } |
| | | |
| | | object obj = new |
| | | { |
| | | x = taskPosition.PutCenterPositionX - putContainer.ContainerLength / 2, |
| | | y = taskPosition.PutCenterPositionY - putContainer.ContainerWidth / 2, |
| | | z = taskPosition.PutCenterPositionZ, |
| | | length, |
| | | width, |
| | | height, |
| | | }; |
| | | |
| | | _webSocketServer.PublishAllClientPayload(obj.Serialize()); |
| | | |
| | | string code = DateTime.Now.ToString("yyyyMMddHHmmss"); |
| | | |
| | | Dt_ContainerItem dt_ContainerItem = new Dt_ContainerItem() |
| | |
| | | ItemLength = length, |
| | | ItemWidth = width, |
| | | ItemHeight = height, |
| | | ItemPositionX = point3D.Value.X, |
| | | ItemPositionY = point3D.Value.Y, |
| | | ItemPositionZ = point3D.Value.Z, |
| | | ItemPositionX = taskPosition.PositionX, |
| | | ItemPositionY = taskPosition.PositionY, |
| | | ItemPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = code |
| | | }; |
| | | |
| | | int positionR = 1; |
| | | |
| | | int takePositionX = 0; |
| | | int takePositionY = 0; |
| | | |
| | | int putPositionX = 0; |
| | | int putPositionY = 0; |
| | | |
| | | int takeContainerPositionX = 0; |
| | | int takeContainerPositionY = 0; |
| | | int takeContainerPositionZ = 0; |
| | | |
| | | int putContainerPositionX = 0; |
| | | int putContainerPositionY = 0; |
| | | int putContainerPositionZ = 0; |
| | | |
| | | int deviceHalfLength = 0; |
| | | int deviceHalfWidth = 0; |
| | | |
| | | if (length > 920 && width >= 300) |
| | | { |
| | | positionR = 1; |
| | | if (OPositions.ZPositions.TryGetValue(takeContainer.ContainerCode, out Position? takeOPosition)) |
| | | { |
| | | takeContainerPositionX = takeOPosition.PositionX; |
| | | takeContainerPositionY = takeOPosition.PositionY; |
| | | takeContainerPositionZ = takeOPosition.PositionZ; |
| | | } |
| | | |
| | | if (OPositions.ZPositions.TryGetValue(putContainer.ContainerCode, out Position? putOPosition)) |
| | | { |
| | | putContainerPositionX = putOPosition.PositionX; |
| | | putContainerPositionY = putOPosition.PositionY; |
| | | putContainerPositionZ = putOPosition.PositionZ; |
| | | } |
| | | |
| | | deviceHalfLength = 460; |
| | | deviceHalfWidth = 265; |
| | | } |
| | | else |
| | | { |
| | | positionR = 0; |
| | | |
| | | if (OPositions.HPositions.TryGetValue(takeContainer.ContainerCode, out Position? takeOPosition)) |
| | | { |
| | | takeContainerPositionX = takeOPosition.PositionX; |
| | | takeContainerPositionY = takeOPosition.PositionY; |
| | | takeContainerPositionZ = takeOPosition.PositionZ; |
| | | } |
| | | |
| | | if (OPositions.HPositions.TryGetValue(putContainer.ContainerCode, out Position? putOPosition)) |
| | | { |
| | | putContainerPositionX = putOPosition.PositionX; |
| | | putContainerPositionY = putOPosition.PositionY; |
| | | putContainerPositionZ = putOPosition.PositionZ; |
| | | } |
| | | |
| | | deviceHalfLength = 265; |
| | | deviceHalfWidth = 460; |
| | | } |
| | | |
| | | //å¸çé¿530 300 é´é660 æå¤§920 å¸ç宽130 |
| | | |
| | | int sourceTakePositionX = 0; |
| | | int sourceTakePositionY = 0; |
| | | |
| | | int sourcePutPositionX = 0; |
| | | int sourceTPutPositionY = 0; |
| | | |
| | | if (length / 2 + point3D.Value.X > 1000) |
| | | { |
| | | takePositionY = 1000; |
| | | putPositionY = putContainerPositionY + 1000; |
| | | |
| | | sourceTakePositionY = 1000; |
| | | sourceTPutPositionY = 1000; |
| | | } |
| | | else |
| | | { |
| | | takePositionY = takeContainerPositionY - length / 2 + deviceHalfLength; |
| | | putPositionY = putContainerPositionY + length / 2 + point3D.Value.X - deviceHalfLength; |
| | | |
| | | sourceTakePositionY = length / 2 + point3D.Value.X + deviceHalfLength; |
| | | sourceTPutPositionY = length / 2 + point3D.Value.X - deviceHalfLength; |
| | | } |
| | | |
| | | |
| | | if (width >= 530) |
| | | { |
| | | takePositionX = takeContainerPositionX + Math.Abs( width / 2 - deviceHalfWidth); |
| | | putPositionX = point3D.Value.Y + putContainerPositionX + Math.Abs(width / 2 - deviceHalfWidth); |
| | | |
| | | sourceTakePositionX = Math.Abs(width / 2 - deviceHalfWidth); |
| | | sourcePutPositionX = point3D.Value.Y + Math.Abs(width / 2 - deviceHalfWidth); |
| | | } |
| | | else |
| | | { |
| | | takePositionX = takeContainerPositionX; |
| | | putPositionX = point3D.Value.Y + takeContainerPositionX; |
| | | |
| | | sourceTakePositionX = 0; |
| | | sourcePutPositionX = point3D.Value.Y; |
| | | } |
| | | |
| | | int takePositionZ = takeContainerPositionZ - (height - (height - 10)); |
| | | int putPositionZ = (putContainerPositionZ - (height - (height - 10))) - point3D.Value.Z; |
| | | |
| | | int sourceTakePositionZ = height - (height - 10); |
| | | int sourcePutPositionZ = height - (height - 10) + point3D.Value.Z; |
| | | |
| | | 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}-{sourceTakePositionX}-{sourceTakePositionY}-{sourceTakePositionZ}-{positionR}", |
| | | TargetAddress = $"{putPosition}-{sourcePutPositionX}-{sourceTPutPositionY}-{sourcePutPositionZ}-{positionR}", |
| | | CurrentAddress = $"{takePosition}-{takePositionX}-{takePositionY}-{takePositionZ}-{positionR}", |
| | | NextAddress = $"{putPosition}-{putPositionX}-{putPositionY}-{putPositionZ}-{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); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¢åä¿¡æ¯çæä»»å¡ |
| | | /// </summary> |
| | | /// <param name="orderInfo">订åä¿¡æ¯</param> |
| | | /// <returns>å
å«ä¸ä¸ªå¼çå
ç»ï¼ <br/> |
| | | /// Item1 - æä½æ¯å¦æå (bool) <br/> |
| | | /// Item2 - çæçä»»å¡å¯¹è±¡ (Dt_Task)ï¼å¤±è´¥æ¶ä¸ºnull <br/> |
| | | /// Item3 - éè¯¯æ¶æ¯ (string)ï¼æåæ¶ä¸ºç©ºå符串 |
| | | /// </returns> |
| | | /// <remarks> |
| | | /// è¯¥æ¹æ³ä¼ï¼ <br/> |
| | | /// 1. æ ¹æ®è®¢å尺寸è·ååéçè´§ä½ <br/> |
| | | /// 2. å建容å¨é¡¹åä»»å¡è®°å½ <br/> |
| | | /// 3. æ´æ°ç¸å
³å®¹å¨ç¶æ <br/> |
| | | /// 4. å¨äºå¡ä¸æ§è¡æææ°æ®åºæä½ |
| | | /// </remarks> |
| | | public (bool, Dt_Task?, string) GenerateTask(OrderInfo orderInfo) |
| | | { |
| | | try |
| | | { |
| | | int length = Convert.ToInt32(orderInfo.Length); |
| | | int width = Convert.ToInt32(orderInfo.Width); |
| | | int height = Convert.ToInt32(orderInfo.Thickness); |
| | | |
| | | var (flag, taskPosition, message) = _containerService.GetPosition(orderInfo.OrderHeadId, orderInfo.OrderNo, length, width, height); |
| | | if (flag && taskPosition != null) |
| | | { |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerCode == taskPosition.PutPosition); |
| | | if (putContainer == null) |
| | | { |
| | | return (false, null, "æªæ¾å°æ¾è´§ä½ç½®"); |
| | | } |
| | | |
| | | Dt_Container? takeContainer = GetTakePosition(putContainer.DeviceCode); |
| | | if (takeContainer == null) |
| | | { |
| | | return (false, null, "æªæ¾å°åè´§ä½ç½®"); |
| | | } |
| | | |
| | | 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, |
| | | }; |
| | | |
| | | int containerLength = putContainer.ContainerLength; |
| | | int containerWidth = putContainer.ContainerWidth; |
| | | int maxValue = Math.Max(length, width); |
| | | int minValue = Math.Min(length, width); |
| | | if (minValue > putContainer.ContainerWidth) |
| | | { |
| | | containerLength = maxValue; |
| | | containerWidth = minValue; |
| | | } |
| | | |
| | | orderContainer.MaxLength = containerLength; |
| | | orderContainer.MaxWidth = containerWidth; |
| | | isAdd = true; |
| | | } |
| | | |
| | | 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.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = orderInfo.Barcode, |
| | | Remark = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}" |
| | | }; |
| | | |
| | | 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 (true, dt_Task, ""); |
| | | } |
| | | else |
| | | { |
| | | return (false, null, message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return (false, null, $"é误,{ex.ExceptionToString()}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éæ°çæä»»å¡ |
| | | /// </summary> |
| | | /// <param name="task">åå§ä»»å¡å¯¹è±¡</param> |
| | | /// <param name="stationCode">å·¥ä½ç«ç¼ç </param> |
| | | /// <returns> |
| | | /// å
å«ä¸ä¸ªå¼çå
ç»ï¼ <br/> |
| | | /// 1. bool - æä½æ¯å¦æå <br/> |
| | | /// 2. Dt_Task - æ´æ°åçä»»å¡å¯¹è±¡ï¼å¤±è´¥æ¶ä¸ºnullï¼ <br/> |
| | | /// 3. string - éè¯¯æ¶æ¯ï¼æåæ¶ä¸ºç©ºåç¬¦ä¸²ï¼ |
| | | /// </returns> |
| | | /// <remarks> |
| | | /// è¯¥æ¹æ³ç¨äºéæ°çæä»»å¡ä¿¡æ¯ï¼å
æ¬ï¼ <br/> |
| | | /// 1. è§£ææ¿åå°ºå¯¸ä¿¡æ¯ <br/> |
| | | /// 2. éªè¯åè´§/æ¾è´§ä½ç½® <br/> |
| | | /// 3. 计ç®ç©åæ¾ç½®ä½ç½® <br/> |
| | | /// 4. æ´æ°ä»»å¡ç¶æåä½ç½®ä¿¡æ¯ <br/> |
| | | /// 5. å¨äºå¡ä¸æ´æ°æ°æ®åºè®°å½ |
| | | /// </remarks> |
| | | public (bool, Dt_Task?, string) RegenerateTask(Dt_Task task, string stationCode) |
| | | { |
| | | try |
| | | { |
| | | int length = 0; |
| | | int width = 0; |
| | | int height = 0; |
| | | Dt_ContainerItem containerItem = _containerItemRepository.QueryFirst(x => x.ItemCode == task.PalletCode); |
| | | if (containerItem == null) |
| | | { |
| | | List<string> itemInfos = task.ItemInfo.Split("*").ToList(); |
| | | if (itemInfos.Count == 3) |
| | | { |
| | | length = Convert.ToInt32(itemInfos[0]); |
| | | width = Convert.ToInt32(itemInfos[1]); |
| | | height = Convert.ToInt32(itemInfos[2]); |
| | | } |
| | | else |
| | | { |
| | | return (false, null, "æ¿å尺寸信æ¯é误"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | length = containerItem.ItemLength; |
| | | width = containerItem.ItemWidth; |
| | | height = containerItem.ItemHeight; |
| | | } |
| | | string containerCode = task.NextAddress.Split("*")[0]; |
| | | |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerCode == containerCode); |
| | | |
| | | if (putContainer == null) |
| | | { |
| | | return (false, null, "æªæ¾å°æ¾è´§ä½ç½®"); |
| | | } |
| | | |
| | | Dt_Container? takeContainer = _containerRepository.QueryFirst(x => x.ContainerCode == stationCode); |
| | | if (takeContainer == null) |
| | | { |
| | | return (false, null, "æªæ¾å°åè´§ä½ç½®"); |
| | | } |
| | | |
| | | var (flag, taskPosition, message) = _containerService.GetPosition(putContainer, length, width, height); |
| | | if (!flag || taskPosition == null) |
| | | { |
| | | return (false, null, message); |
| | | } |
| | | |
| | | Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(x => x.ContainerCode == putContainer.ContainerCode); |
| | | |
| | | bool isAdd = false; |
| | | |
| | | if (orderContainer == null) |
| | | { |
| | | return (false, null, "æªæ¾å°è®¢åä¸å®¹å¨ç»å®å
³ç³»"); |
| | | } |
| | | |
| | | int containerLength = putContainer.ContainerLength; |
| | | int containerWidth = putContainer.ContainerWidth; |
| | | int maxValue = Math.Max(length, width); |
| | | int minValue = Math.Min(length, width); |
| | | if (minValue > putContainer.ContainerWidth) |
| | | { |
| | | containerLength = maxValue; |
| | | containerWidth = minValue; |
| | | } |
| | | |
| | | orderContainer.MaxLength = containerLength; |
| | | orderContainer.MaxWidth = containerWidth; |
| | | |
| | | if (containerItem == null) |
| | | { |
| | | containerItem = new Dt_ContainerItem() |
| | | { |
| | | ContainerId = putContainer.Id, |
| | | ItemCode = task.PalletCode, |
| | | ItemLength = length, |
| | | ItemWidth = width, |
| | | ItemHeight = height, |
| | | ItemPositionX = taskPosition.PositionX, |
| | | ItemPositionY = taskPosition.PositionY, |
| | | ItemPositionZ = taskPosition.PositionZ, |
| | | ItemRelaPositionX = taskPosition.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = task.PalletCode, |
| | | Remark = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}" |
| | | }; |
| | | isAdd = true; |
| | | } |
| | | else |
| | | { |
| | | containerItem.ItemLength = length; |
| | | containerItem.ItemWidth = width; |
| | | containerItem.ItemHeight = height; |
| | | containerItem.ItemPositionX = taskPosition.PositionX; |
| | | containerItem.ItemPositionY = taskPosition.PositionY; |
| | | containerItem.ItemPositionZ = taskPosition.PositionZ; |
| | | containerItem.ItemRelaPositionX = taskPosition.PutPositionX; |
| | | containerItem.ItemRelaPositionY = taskPosition.PutPositionY; |
| | | containerItem.ItemRelaPositionZ = taskPosition.PutPositionZ; |
| | | containerItem.ItemStatus = (int)ItemStatusEnum.Assigned; |
| | | containerItem.Remark = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}"; |
| | | } |
| | | |
| | | task.TaskState = (int)TaskStatusEnum.Gantry_New; |
| | | task.CurrentAddress = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}"; |
| | | task.NextAddress = $"{putContainer.ContainerCode}*{taskPosition.PutPositionX}*{taskPosition.PutPositionY}*{taskPosition.PutPositionZ}*{taskPosition.PositionR}"; |
| | | task.ItemInfo = $"{length}*{width}*{height}"; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.UpdateData(task); |
| | | _containerRepository.UpdateData(putContainer); |
| | | _orderContainerRepository.UpdateData(orderContainer); |
| | | |
| | | if (isAdd) |
| | | { |
| | | _containerItemRepository.AddData(containerItem); |
| | | } |
| | | else |
| | | { |
| | | _containerItemRepository.UpdateData(containerItem); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return (true, task, ""); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return (false, null, $"é误,{ex.ExceptionToString()}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå¼å¸¸ä»»å¡ |
| | | /// </summary> |
| | | /// <param name="orderInfo">订åä¿¡æ¯</param> |
| | | /// <returns>å
ç»å
å«ä¸ä¸ªå¼ï¼ <br/> |
| | | /// Item1 - æä½æ¯å¦æåï¼boolï¼ <br/> |
| | | /// Item2 - çæçä»»å¡å¯¹è±¡ï¼Dt_Taskï¼ï¼å¤±è´¥æ¶ä¸ºnull <br/> |
| | | /// Item3 - éè¯¯æ¶æ¯ï¼stringï¼ï¼æåæ¶ä¸ºç©ºå符串</returns> |
| | | /// <remarks> |
| | | /// è¯¥æ¹æ³ä¼æ ¹æ®è®¢åä¿¡æ¯çæä¸ä¸ªå¼å¸¸å¤çä»»å¡ï¼å
æ¬ï¼ <br/> |
| | | /// 1. è·åå¼å¸¸ä½ç½® <br/> |
| | | /// 2. éªè¯æ¾è´§/åè´§ä½ç½® <br/> |
| | | /// 3. å建容å¨é¡¹åä»»å¡è®°å½ <br/> |
| | | /// 4. æäº¤äºå¡ |
| | | /// </remarks> |
| | | public (bool, Dt_Task?, string) GenerateExceptionTask(OrderInfo orderInfo) |
| | | { |
| | | int length = Convert.ToInt32(orderInfo.Length); |
| | | int width = Convert.ToInt32(orderInfo.Width); |
| | | int height = Convert.ToInt32(orderInfo.Thickness); |
| | | |
| | | var (flag, taskPosition, message) = _containerService.GetExceptionPosition(length, width, height); |
| | | if (flag && taskPosition != null) |
| | | { |
| | | Dt_Container putContainer = _containerRepository.QueryFirst(x => x.ContainerCode == taskPosition.PutPosition); |
| | | if (putContainer == null) |
| | | { |
| | | return (false, null, "æªæ¾å°æ¾è´§ä½ç½®"); |
| | | } |
| | | |
| | | Dt_Container? takeContainer = GetTakePosition(putContainer.DeviceCode); |
| | | if (takeContainer == null) |
| | | { |
| | | return (false, 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.PutPositionX, |
| | | ItemRelaPositionY = taskPosition.PutPositionY, |
| | | ItemRelaPositionZ = taskPosition.PutPositionZ, |
| | | ItemStatus = (int)ItemStatusEnum.Assigned, |
| | | ItemName = orderInfo.Barcode, |
| | | Remark = $"{takeContainer.ContainerCode}*{taskPosition.TakePositionX}*{taskPosition.TakePositionY}*{taskPosition.TakePositionZ}*{taskPosition.PositionR}" |
| | | }; |
| | | |
| | | 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, |
| | | }; |
| | | |
| | | if (taskPosition.TakeCenterPositionZ == 99) |
| | | { |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Gantry_BeRelease; |
| | | } |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(dt_Task); |
| | | _containerItemRepository.AddData(dt_ContainerItem); |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | return (true, dt_Task, ""); |
| | | } |
| | | else |
| | | { |
| | | return (false, null, message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¾å¤ç¼å·è·ååè´§ä½ç½® |
| | | /// </summary> |
| | | /// <param name="deviceCode">设å¤ç¼å·</param> |
| | | /// <returns>ç¬¦åæ¡ä»¶ç容å¨å¯¹è±¡ï¼è¥æ¾ä¸å°åè¿ånull</returns> |
| | | /// <remarks> |
| | | /// 1. é¦å
æ¥è¯¢æå®è®¾å¤ä¸ææå¯ç¨çå货容å¨ï¼å¹¶æContainerSortååºæåº <br/> |
| | | /// 2. æ¥æ¾è¯¥è®¾å¤æè¿çä»»å¡è®°å½ <br/> |
| | | /// 3. 妿æ¾å°ä»»å¡è®°å½ï¼åæ ¹æ®ä»»å¡æºå°åå¹é
容å¨ï¼è¿åä¸ä¸ä¸ªå®¹å¨(è¥å·²æ¯æåä¸ä¸ªåè¿å第ä¸ä¸ª) <br/> |
| | | /// 4. 妿åºç°å¼å¸¸ææªæ¾å°å¹é
项ï¼åè¿å第ä¸ä¸ªå¯ç¨å®¹å¨ |
| | | /// </remarks> |
| | | 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(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å®æå¤çæ¹æ³ |
| | | /// </summary> |
| | | /// <param name="task">ä»»å¡å®ä½</param> |
| | | /// <returns>Webååºå
容</returns> |
| | | /// <remarks> |
| | | /// 1. æ´æ°ä»»å¡ç¶æä¸º"é¾é¨æ¶å®æ" <br/> |
| | | /// 2. æ´æ°ç¸å
³è®¢å详æ
ç¶æä¸º"ç åæå" <br/> |
| | | /// 3. æ´æ°è®¢åè¡ä¸çæçæ°é <br/> |
| | | /// 4. æ ¹æ®ä»»å¡å®ææ
åµåéWebSocketéç¥ <br/> |
| | | /// 5. è®°å½æä½æ¥å¿å¹¶æäº¤äºå¡ <br/> |
| | | /// 6. å¼å¸¸æ¶åæ»äºå¡å¹¶è¿åéè¯¯ä¿¡æ¯ |
| | | /// </remarks> |
| | | 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)); |
| | | |
| | | _orderDetailsRepository.UpdateData(orderDetails); |
| | | _orderrowsRepository.UpdateData(orderrows); |
| | | |
| | | if (container.ContainerType == ContainerTypeEnum.ExceptionContainer.ObjToInt()) |
| | | { |
| | | int count = Db.Queryable<Dt_ContainerItem>().Count(x => x.ContainerId == container.Id); |
| | | if (count >= 5) |
| | | { |
| | | if (LightStatusStorage.LightStatusDic.ContainsKey(container.ContainerCode)) |
| | | { |
| | | LightStatusStorage.LightStatusDic[container.ContainerCode] = LightStatusEnum.LightError; |
| | | } |
| | | } |
| | | } |
| | | |
| | | try |
| | | { |
| | | 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(); |
| | | |
| | | List<object> orderData = new List<object>(); |
| | | foreach (var item in details) |
| | | { |
| | | object obj = new |
| | | { |
| | | name = item.Orderdetails_name, |
| | | baseName = item.Orderdetails_productName, |
| | | size = $"{item.Orderdetails_length}*{item.Orderdetails_width}*{item.Orderdetails_thickness}", |
| | | process = "", |
| | | }; |
| | | orderData.Add(obj); |
| | | } |
| | | object data = new |
| | | { |
| | | orderCode = orderrows.Orderrows_orderid, |
| | | orderName = orderrows.Orderrows_name, |
| | | cusName = orderrows.Orderrows_customer, |
| | | stationCode = container.ContainerCode, |
| | | orderTotalNum = totalDetails.Count, |
| | | sortedNum = sortedNum, |
| | | unsortedNum = totalDetails.Count - sortedNum, |
| | | stationSortedNum = details.Count, |
| | | orderData = orderData, |
| | | orderId = orderrows.id, |
| | | release = 0 |
| | | }; |
| | | |
| | | |
| | | _webSocketServer.PublishAllClientPayload(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); |
| | | } |
| | | } |
| | | } |
| | | } |