| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using AutoMapper; |
| | | using HslCommunication.WebSocket; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_BasicInfoService; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Core; |
| | |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_IBasicInfoRepository; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEAWCS_BasicInfoService |
| | | { |
| | | /// <summary> |
| | | /// 容卿å¡ç±»ï¼æä¾å®¹å¨ç¸å
³çä¸å¡é»è¾æä½ |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// 主è¦åè½å
æ¬ï¼ <br/> |
| | | /// 1. è·åç©åå¨å®¹å¨ä¸çæ¾ç½®ä½ç½® <br/> |
| | | /// 2. å¤çå¼å¸¸å·¥ä½çä½ç½®åé
<br/> |
| | | /// 3. æ ¹æ®è®¢åæå°ºå¯¸è·ååéçä½ç½® <br/> |
| | | /// 4. 鿾容å¨èµæº <br/> |
| | | /// 使ç¨ä¾èµæ³¨å
¥æ¹å¼è·åä»å¨æ¥å£åå·¥ä½åå
管ç |
| | | /// </remarks> |
| | | public class ContainerService : ServiceBase<Dt_Container, IContainerRepository>, IContainerService |
| | | { |
| | | /// <summary> |
| | | /// ç¨äºå¯¹è±¡æ å°çæ å°å¨å®ä¾ |
| | | /// </summary> |
| | | private readonly IMapper _mapper; |
| | | /// <summary> |
| | | /// å·¥ä½åå
ç®¡çæ¥å£å®ä¾ï¼ç¨äºç®¡çæ°æ®åºäºå¡åå·¥ä½åå
|
| | | /// </summary> |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | /// <summary> |
| | | /// 容å¨ç©åä»å¨æ¥å£å®ä¾ |
| | | /// </summary> |
| | | private readonly IContainerItemRepository _containerItemRepository; |
| | | /// <summary> |
| | | /// 订å容å¨ä»å¨æ¥å£å®ä¾ |
| | | /// </summary> |
| | | private readonly IOrderContainerRepository _orderContainerRepository; |
| | | /// <summary> |
| | | /// ä»»å¡ä»å¨æ¥å£å®ä¾ï¼ç¨äºæä½ä»»å¡æ°æ® |
| | | /// </summary> |
| | | private readonly ITaskRepository _taskRepository; |
| | | /// <summary> |
| | | /// WebSocketæå¡å¨å®ä¾ï¼ç¨äºå¤ç宿¶éä¿¡ |
| | | /// </summary> |
| | | private readonly WebSocketServer _webSocketServer; |
| | | |
| | | public ContainerService(IContainerRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IContainerItemRepository containerItemRepository, IOrderContainerRepository orderContainerRepository) : base(BaseDal) |
| | | /// <summary> |
| | | /// 容卿塿é 彿° |
| | | /// </summary> |
| | | /// <param name="BaseDal">容å¨ä»å¨æ¥å£</param> |
| | | /// <param name="mapper">对象æ å°å¨</param> |
| | | /// <param name="unitOfWorkManage">å·¥ä½åå
管çå¨</param> |
| | | /// <param name="containerItemRepository">容å¨é¡¹ä»å¨æ¥å£</param> |
| | | /// <param name="orderContainerRepository">订å容å¨ä»å¨æ¥å£</param> |
| | | /// <param name="taskRepository">ä»»å¡ä»å¨æ¥å£</param> |
| | | /// <param name="webSocketServer">WebSocketæå¡å®ä¾</param> |
| | | public ContainerService(IContainerRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IContainerItemRepository containerItemRepository, IOrderContainerRepository orderContainerRepository, ITaskRepository taskRepository, WebSocketServer webSocketServer) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _containerItemRepository = containerItemRepository; |
| | | _orderContainerRepository = orderContainerRepository; |
| | | } |
| | | |
| | | public SuctionInfo GetPlacementResult(Block block, List<Block> blocks) |
| | | { |
| | | ContainerPlacer containerPlacer = new ContainerPlacer(); |
| | | |
| | | |
| | | return containerPlacer.CalculatePlacement(block, blocks); |
| | | _taskRepository = taskRepository; |
| | | _webSocketServer = webSocketServer; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæ¾ç½®ä½ç½® |
| | | /// è·åä»»å¡ä½ç½®ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="length"></param> |
| | | /// <param name="width"></param> |
| | | /// <param name="height"></param> |
| | | /// <param name="containerSize"></param> |
| | | /// <param name="placedBlocks"></param> |
| | | /// <param name="edge">è¾¹</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | /// <param name="length">ç©åé¿åº¦</param> |
| | | /// <param name="width">ç©å宽度</param> |
| | | /// <param name="height">ç©åé«åº¦</param> |
| | | /// <param name="containerSize">容å¨å°ºå¯¸</param> |
| | | /// <param name="placedBlocks">å·²æ¾ç½®åå表</param> |
| | | /// <param name="edge">è¾¹ç¼åæ°</param> |
| | | /// <returns>è¿åä»»å¡ä½ç½®ä¿¡æ¯ï¼è¥æ¾ç½®å¤±è´¥åè¿ånull</returns> |
| | | /// <exception cref="Exception">彿¾ç½®è¿ç¨ä¸åçéè¯¯æ¶æåºå¼å¸¸</exception> |
| | | public TaskPosition? GetTaskPosition(int length, int width, int height, ContainerSize containerSize, List<PlacedBlock> placedBlocks, int edge) |
| | | { |
| | | try |
| | | { |
| | | |
| | | PlaceBlockService placeBlockService = new PlaceBlockService(containerSize, placedBlocks); |
| | | |
| | | TaskPosition? taskPosition = placeBlockService.PlaceBlock(length, width, height, edge); |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åå¼å¸¸å·¥ä½ä½ç½® |
| | | /// </summary> |
| | | /// <param name="length">ç©åé¿åº¦</param> |
| | | /// <param name="width">ç©å宽度</param> |
| | | /// <param name="height">ç©åé«åº¦</param> |
| | | /// <returns>å
ç»å
å«ä¸ä¸ªå¼ï¼æ¯å¦æåè·åãä»»å¡ä½ç½®å¯¹è±¡(失败æ¶ä¸ºnull)ãé误信æ¯(æåæ¶ä¸ºç©º)</returns> |
| | | /// <remarks> |
| | | /// å½å¼å¸¸å®¹å¨ä¸ç©åæ°éâ¥5æ¶ï¼ä½¿ç¨åºå®Zè½´ä½ç½®99ï¼å¦åæ ¹æ®å½åç©åæ°é计ç®ä½ç½® |
| | | /// </remarks> |
| | | public (bool, TaskPosition?, string) GetExceptionPosition(int length, int width, int height) |
| | | { |
| | | Dt_Container? container = Db.Queryable<Dt_Container>().Where(x => x.ContainerType == ContainerTypeEnum.ExceptionContainer.ObjToInt()).Includes(x => x.Items).First(); |
| | | if (container == null) |
| | | { |
| | | return (false, null, "请é
ç½®å¼å¸¸å·¥ä½"); |
| | | } |
| | | |
| | | if (container.Items.Count >= 5) |
| | | { |
| | | ContainerSize containerSize = new ContainerSize(container.ContainerLength, container.ContainerWidth, container.ContainerHeight); |
| | | ExceptionPlaceBlockService exceptionPlaceBlockService = new ExceptionPlaceBlockService(containerSize); |
| | | TaskPosition taskPosition = exceptionPlaceBlockService.ExceptionPlaceBlock(length, width, height, 0); |
| | | taskPosition.TakeCenterPositionZ = 99; |
| | | taskPosition.PutPosition = container.ContainerCode; |
| | | if (LightStatusStorage.LightStatusDic.ContainsKey(container.ContainerCode)) |
| | | { |
| | | LightStatusStorage.LightStatusDic[container.ContainerCode] = LightStatusEnum.LightError; |
| | | } |
| | | return (true, taskPosition, ""); |
| | | } |
| | | else |
| | | { |
| | | ContainerSize containerSize = new ContainerSize(container.ContainerLength, container.ContainerWidth, container.ContainerHeight); |
| | | ExceptionPlaceBlockService exceptionPlaceBlockService = new ExceptionPlaceBlockService(containerSize); |
| | | TaskPosition taskPosition = exceptionPlaceBlockService.ExceptionPlaceBlock(length, width, height, container.Items.Count); |
| | | taskPosition.PutPosition = container.ContainerCode; |
| | | return (true, taskPosition, ""); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¢åä¿¡æ¯æå°ºå¯¸è·åä»»å¡ä½ç½® |
| | | /// </summary> |
| | | /// <param name="orderId">订åID</param> |
| | | /// <param name="orderNo">订åç¼å·</param> |
| | | /// <param name="length">é¿åº¦</param> |
| | | /// <param name="width">宽度</param> |
| | | /// <param name="height">é«åº¦</param> |
| | | /// <returns> |
| | | /// è¿åå
ç»å
å«ä¸ä¸ªå¼ï¼ <br/> |
| | | /// Item1 - æ¯å¦æåè·åä½ç½® <br/> |
| | | /// Item2 - è·åå°çä»»å¡ä½ç½®å¯¹è±¡ï¼å¯è½ä¸ºnull <br/> |
| | | /// Item3 - é误代ç ï¼æåæ¶è¿å空å符串 |
| | | /// </returns> |
| | | public (bool, TaskPosition?, string) GetPosition(int orderId, string orderNo, int length, int width, int height) |
| | | { |
| | | TaskPosition? taskPosition = GetPositionByOrder(orderId, orderNo, length, width, height); |
| | |
| | | { |
| | | return (true, taskPosition, ""); |
| | | } |
| | | return (true, taskPosition, "10001"); |
| | | return (false, null, "10001"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®ç©å尺寸è·ååéç容å¨ä½ç½® |
| | | /// </summary> |
| | | /// <param name="length">ç©åé¿åº¦</param> |
| | | /// <param name="width">ç©å宽度</param> |
| | | /// <param name="height">ç©åé«åº¦</param> |
| | | /// <returns>è¿åæ¾å°çä»»å¡ä½ç½®ä¿¡æ¯ï¼å
å«å®¹å¨ç¼ç ï¼è¥æªæ¾å°åéä½ç½®åè¿ånull</returns> |
| | | /// <remarks> |
| | | /// è¯¥æ¹æ³ä¼æ¥è¯¢ææå¯ç¨ç©ºå®¹å¨ï¼å¹¶æ ¹æ®ç©å尺寸å容å¨ç¶æå¤ææ¯å¦éåæ¾ç½®ã <br/> |
| | | /// 对äºè¶
大ç©å(é¿æå®½è¶
è¿1600)ææç¹æ®è¦æ±ç容å¨ä¼è¿è¡ç¹æ®å¤çã |
| | | /// </remarks> |
| | | public TaskPosition? GetPosition(int length, int width, int height) |
| | | { |
| | | List<Dt_Container> containers = Db.Queryable<Dt_Container>().Where(x => x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()).Includes(x => x.Items).ToList(); |
| | | |
| | | Dt_Container? container = containers.OrderBy(x => x.ContainerSort).FirstOrDefault(x => x.ContainerStatus == ContainerStatusEnum.Empty.ObjToInt() && x.ContainerEnable); |
| | | List<PlacedBlock> placedBlocks = new List<PlacedBlock>(); |
| | | if (container != null && (containers.Any(x => (x.Items.Any(v => v.ItemLength > 1600 || v.ItemWidth > 1600)) && x.DeviceCode == container.DeviceCode) || containers.Where(x => x.ContainerStatus == ContainerStatusEnum.Empty.ObjToInt() && x.ContainerEnable && x.DeviceCode == container.DeviceCode).Count() > 1 || length > 1600 || width > 1600)) |
| | | if (container != null) |
| | | { |
| | | int edge = 0; |
| | | if (container.ContainerNo == containers.Where(x => x.DeviceCode == container.DeviceCode && x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()).Min(x => x.ContainerNo)) |
| | | { |
| | | edge = 1; |
| | | } |
| | | |
| | | ContainerSize containerSize = new ContainerSize(container.ContainerLength, container.ContainerWidth, container.ContainerHeight); |
| | | int containerLength = container.ContainerLength; |
| | | int containerWidth = container.ContainerWidth; |
| | | int maxValue = Math.Max(length, width); |
| | | int minValue = Math.Min(length, width); |
| | | if (minValue > container.ContainerWidth) |
| | | { |
| | | containerLength = maxValue; |
| | | containerWidth = minValue; |
| | | } |
| | | ContainerSize containerSize = new ContainerSize(containerLength, containerWidth, container.ContainerHeight); |
| | | TaskPosition? taskPosition = GetTaskPosition(length, width, height, containerSize, placedBlocks, edge); |
| | | if (taskPosition != null) |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæå®å®¹å¨ä¸çå¯ç¨ä½ç½® |
| | | /// </summary> |
| | | /// <param name="container">ç®æ 容å¨å¯¹è±¡</param> |
| | | /// <param name="length">å¾
æ¾ç½®ç©åé¿åº¦</param> |
| | | /// <param name="width">å¾
æ¾ç½®ç©å宽度</param> |
| | | /// <param name="height">å¾
æ¾ç½®ç©åé«åº¦</param> |
| | | /// <returns>å
ç»å
å«ï¼ <br/> |
| | | /// - bool: æ¯å¦æ¾å°åéä½ç½® <br/> |
| | | /// - TaskPosition?: æ¾å°çä»»å¡ä½ç½®ä¿¡æ¯(å¯ä¸ºnull) <br/> |
| | | /// - string: é误代ç (æåæ¶è¿å空å符串) |
| | | /// </returns> |
| | | /// <remarks> |
| | | /// æ¹æ³ä¼æ£æ¥å®¹å¨å°ºå¯¸æ¯å¦æ»¡è¶³ç©åæ¾ç½®è¦æ±ï¼ <br/> |
| | | /// å¹¶èè容å¨è¾¹ç¼æ
åµè®¡ç®æä½³æ¾ç½®ä½ç½® |
| | | /// </remarks> |
| | | public (bool, TaskPosition?, string) GetPosition(Dt_Container container, int length, int width, int height) |
| | | { |
| | | List<Dt_Container> containers = Db.Queryable<Dt_Container>().Where(x => x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()).Includes(x => x.Items).ToList(); |
| | | List<PlacedBlock> placedBlocks = new List<PlacedBlock>(); |
| | | if (container != null) |
| | | { |
| | | int edge = 0; |
| | | if (container.ContainerNo == containers.Where(x => x.DeviceCode == container.DeviceCode && x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()).Min(x => x.ContainerNo)) |
| | | { |
| | | edge = 1; |
| | | } |
| | | int containerLength = container.ContainerLength; |
| | | int containerWidth = container.ContainerWidth; |
| | | int maxValue = Math.Max(length, width); |
| | | int minValue = Math.Min(length, width); |
| | | if (minValue > container.ContainerWidth) |
| | | { |
| | | containerLength = maxValue; |
| | | containerWidth = minValue; |
| | | } |
| | | ContainerSize containerSize = new ContainerSize(containerLength, containerWidth, container.ContainerHeight); |
| | | TaskPosition? taskPosition = GetTaskPosition(length, width, height, containerSize, placedBlocks, edge); |
| | | if (taskPosition != null) |
| | | { |
| | | taskPosition.PutPosition = container.ContainerCode; |
| | | return (true, taskPosition, ""); |
| | | } |
| | | } |
| | | |
| | | return (false, null, "10002"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®è®¢åä¿¡æ¯è·åå¯ç¨è´§ä½ä½ç½® |
| | | /// </summary> |
| | | /// <param name="orderId">订åID</param> |
| | | /// <param name="orderNo">订åç¼å·</param> |
| | | /// <param name="length">ç©åé¿åº¦</param> |
| | | /// <param name="width">ç©å宽度</param> |
| | | /// <param name="height">ç©åé«åº¦</param> |
| | | /// <returns>è¿åç¬¦åæ¡ä»¶çä»»å¡ä½ç½®ä¿¡æ¯ï¼è¥æ¾ä¸å°åè¿ånull</returns> |
| | | /// <remarks> |
| | | /// è¯¥æ¹æ³ä¼æ¥è¯¢è®¢åå
³èç容å¨ï¼å¹¶æ£æ¥æ¯ä¸ªå®¹å¨ä¸å·²æ¾ç½®ç©åçå¸å±ï¼ <br/> |
| | | /// éè¿ç®æ³è®¡ç®æ°ç©åå¨å®¹å¨ä¸çæä½³æ¾ç½®ä½ç½® |
| | | /// </remarks> |
| | | public TaskPosition? GetPositionByOrder(int orderId, string orderNo, int length, int width, int height) |
| | | { |
| | | List<Dt_OrderContainer> orderContainers = Db.Queryable<Dt_OrderContainer>().Where(it => it.OrderNo == orderNo && it.OrderId == orderId).ToList(); |
| | |
| | | Point3D point3D = new Point3D(item.ItemPositionX, item.ItemPositionY, item.ItemPositionZ); |
| | | placedBlocks.Add(new PlacedBlock(point3D, tempLength, tempWidth, item.ItemHeight)); |
| | | } |
| | | Dt_OrderContainer? orderContainer = orderContainers.FirstOrDefault(x => x.ContainerId == x.Id && x.ContainerCode == x.ContainerCode); |
| | | Dt_OrderContainer? orderContainer = orderContainers.FirstOrDefault(x => x.ContainerId == container.Id && x.ContainerCode == container.ContainerCode); |
| | | if (orderContainer == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | int edge = 0; |
| | | if (container.ContainerNo == dt_Containers.Where(x => x.DeviceCode == container.DeviceCode && x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt()).Min(x => x.ContainerNo)) |
| | |
| | | edge = 1; |
| | | } |
| | | |
| | | ContainerSize containerSize = new ContainerSize(container.ContainerLength, container.ContainerWidth, container.ContainerHeight); |
| | | ContainerSize containerSize = new ContainerSize(orderContainer.MaxLength, orderContainer.MaxWidth, container.ContainerHeight); |
| | | TaskPosition? taskPosition = GetTaskPosition(length, width, height, containerSize, placedBlocks, edge); |
| | | if (taskPosition != null) |
| | | { |
| | | taskPosition.PutPosition = container.ContainerCode; |
| | | return taskPosition; |
| | | } |
| | | //else |
| | | //{ |
| | | // if (LightStatusStorage.LightStatusDic.ContainsKey(container.ContainerCode))//LightStatusEnum |
| | | // { |
| | | // LightStatusStorage.LightStatusDic[container.ContainerCode] = LightStatusEnum.ReadyRelease; |
| | | |
| | | // if (container.Items.Count > 10) |
| | | // { |
| | | // container.ContainerStatus = ContainerStatusEnum.ReadyRelease.ObjToInt(); |
| | | // BaseDal.UpdateData(container); |
| | | // } |
| | | |
| | | // } |
| | | //} |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éæ¾æå®å®¹å¨åå
¶å
³è项 |
| | | /// </summary> |
| | | /// <param name="keys">容å¨IDæ°ç»</param> |
| | | /// <returns>æä½ç»æååº</returns> |
| | | /// <remarks> |
| | | /// 1. æ¥è¯¢å¹¶è·åæå®å®¹å¨åå
¶å
³è项 <br/> |
| | | /// 2. æ´æ°å®¹å¨ç¶æä¸ºç©ºé² <br/> |
| | | /// 3. å¨äºå¡ä¸æ§è¡ä»¥ä¸æä½ï¼ <br/> |
| | | /// - å é¤å®¹å¨é¡¹å¹¶ç§»å
¥åå²è¡¨ <br/> |
| | | /// - å é¤è®¢å容å¨å
³èå¹¶ç§»å
¥åå²è¡¨ <br/> |
| | | /// - æ´æ°å®¹å¨ç¶æ <br/> |
| | | /// 4. æä½æåè¿åOKï¼å¤±è´¥åæ»äºå¡å¹¶è¿åéè¯¯ä¿¡æ¯ |
| | | /// </remarks> |
| | | public WebResponseContent ReleaseContainer(int[] keys) |
| | | { |
| | | try |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent AutoReleaseContainer(int[] keys) |
| | | { |
| | | try |
| | | { |
| | | List<Dt_Container> containers = Db.Queryable<Dt_Container>().Where(x => keys.Contains(x.Id)).Includes(x => x.Items).ToList(); |
| | | |
| | | for (int i = 0; i < containers.Count; i++) |
| | | { |
| | | AutoReleaseContainer(containers[i].ContainerCode); |
| | | } |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// èªå¨éæ¾å®¹å¨ |
| | | /// </summary> |
| | | /// <param name="containerCode">容å¨ç¼å·</param> |
| | | /// <returns>Webååºç»æ</returns> |
| | | /// <remarks> |
| | | /// 1. æ ¹æ®å®¹å¨ç¼å·æ¥è¯¢å®¹å¨ä¿¡æ¯ <br/> |
| | | /// 2. æ£æ¥å®¹å¨æ¯å¦åå¨å
³èä»»å¡ <br/> |
| | | /// 3. è¥æ ä»»å¡åæ¸
空容å¨ç¶æå¹¶å é¤è®¢å容å¨è®°å½ <br/> |
| | | /// 4. è¥æä»»å¡åæ´æ°ä»»å¡ç¶æä¸º"é¾é¨æ¶éæ°åé
" <br/> |
| | | /// 5. äºå¡å¤çæææ°æ®åºæä½ |
| | | /// </remarks> |
| | | public WebResponseContent AutoReleaseContainer(string containerCode) |
| | | { |
| | | try |
| | | { |
| | | Dt_Container container = BaseDal.QueryFirst(x => x.ContainerCode == containerCode); |
| | | if (container == null) |
| | | { |
| | | return WebResponseContent.Instance.Error("容å¨ä¸åå¨"); |
| | | } |
| | | |
| | | if (container.ContainerStatus == ContainerStatusEnum.Empty.ObjToInt()) |
| | | { |
| | | return WebResponseContent.Instance.Error("容å¨å·²å¤äºç©ºé²ç¶æ"); |
| | | } |
| | | |
| | | if (container.ContainerType == ContainerTypeEnum.ExceptionContainer.ObjToInt()) |
| | | { |
| | | if (container.Items != null && container.Items.Count > 0) |
| | | { |
| | | _containerItemRepository.DeleteAndMoveIntoHty(container.Items, App.User?.UserId > 0 ? WIDESEAWCS_Core.Enums.OperateTypeEnum.人工å é¤ : WIDESEAWCS_Core.Enums.OperateTypeEnum.èªå¨å é¤); |
| | | } |
| | | return WebResponseContent.Instance.OK("å¼å¸¸å·¥ä½å·²éæ¾"); |
| | | } |
| | | List<Dt_Task> tasks = _taskRepository.QueryData(x => x.NextAddress.Contains(container.ContainerCode)); |
| | | |
| | | Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(x => x.ContainerCode == container.ContainerCode && x.ContainerId == container.Id); |
| | | |
| | | if (tasks != null && tasks.Count > 0) |
| | | { |
| | | List<string> codes = tasks.Select(x => x.PalletCode).ToList(); |
| | | |
| | | container.Items = _containerItemRepository.QueryData(x => x.ContainerId == container.Id && !codes.Contains(x.ItemCode)); |
| | | |
| | | if (container.ContainerType == ContainerTypeEnum.ExceptionContainer.ObjToInt()) |
| | | { |
| | | tasks.ForEach(x => |
| | | { |
| | | if (x.TaskState == TaskStatusEnum.Gantry_BeRelease.ObjToInt()) |
| | | { |
| | | x.TaskState = TaskStatusEnum.Gantry_New.ObjToInt(); |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | tasks.ForEach(x => |
| | | { |
| | | if (x.TaskState == TaskStatusEnum.Gantry_Wait.ObjToInt()) |
| | | { |
| | | x.TaskState = TaskStatusEnum.Gantry_BeReassign.ObjToInt(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | container.Items = _containerItemRepository.QueryData(x => x.ContainerId == container.Id); |
| | | } |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | if (container.Items != null && container.Items.Count > 0) |
| | | { |
| | | _containerItemRepository.DeleteAndMoveIntoHty(container.Items, App.User?.UserId > 0 ? WIDESEAWCS_Core.Enums.OperateTypeEnum.人工å é¤ : WIDESEAWCS_Core.Enums.OperateTypeEnum.èªå¨å é¤); |
| | | } |
| | | |
| | | if (tasks == null || tasks.Count == 0) |
| | | { |
| | | container.ContainerStatus = ContainerStatusEnum.Empty.ObjToInt(); |
| | | |
| | | BaseDal.UpdateData(container); |
| | | if (orderContainer != null) |
| | | { |
| | | _orderContainerRepository.DeleteAndMoveIntoHty(orderContainer, App.User?.UserId > 0 ? WIDESEAWCS_Core.Enums.OperateTypeEnum.人工å é¤ : WIDESEAWCS_Core.Enums.OperateTypeEnum.èªå¨å é¤); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | orderContainer.MaxLength = container.ContainerLength; |
| | | orderContainer.MaxWidth = container.ContainerWidth; |
| | | _orderContainerRepository.UpdateData(orderContainer); |
| | | _taskRepository.UpdateData(tasks); |
| | | } |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | |
| | | //_webSocketServeråéæ°æ® |
| | | _webSocketServer.PublishAllClientPayload(new |
| | | { |
| | | stationCode = container.ContainerCode, |
| | | release = 1, |
| | | }.Serialize()); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |