z8018
2025-05-20 745aa71a76544989535ff193f3ede69200bab2db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.PlacedBlockDTO;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_IBasicInfoService;
 
namespace WIDESEAWCS_BasicInfoService
{
    public class ExceptionPlaceBlockService
    {
        public ContainerSize ContainerSize { get; private set; }
 
        /// <summary>
        /// 最小横向Y坐标限制(毫米)
        /// </summary>
        public static int MinY = AppSettings.GetValue("MinY").ObjToInt();
 
        /// <summary>
        /// 最大Y坐标限制(毫米)
        /// </summary>
        public const int MaxY = 600;
 
        public ExceptionPlaceBlockService(ContainerSize containerSize)
        {
            ContainerSize = containerSize;
        }
 
        public TaskPosition ExceptionPlaceBlock(int length, int width, int height, int count)
        {
            int tempLength = length;
            int tempWidth = width;
            if (length < width)
            {
                length = tempWidth;
                width = tempLength;
            }
 
            int takePositionX = 0;
            int takePositionY = 0;
            int takePositionZ = 0;
            int putPositionX = 0;
            int putPositionY = 0;
            int putPositionZ = 0;
 
            Point3D deviceCenter = new Point3D(530 / 2, 920 / 2, 0);
            if (length <= 920) //横向双吸
            {
                deviceCenter = new Point3D(530 / 2, 130 / 2, 0);
            }
 
            takePositionX = width / 2 - deviceCenter.X - MinY / 2;
            takePositionY = length / 2 - deviceCenter.Y;
            takePositionZ = 10;
 
            putPositionX = ContainerSize.Width / 2 - deviceCenter.X;
            putPositionY = takePositionY;
            putPositionZ = count * height;
 
            if (takePositionY < MinY)
            {
                takePositionY = 0;
                putPositionY = MinY;
            }
            else if (putPositionY > MaxY)
            {
                int moreY = putPositionY - MaxY;
                if (takePositionY - moreY > 0)
                {
                    takePositionY -= moreY;
                    putPositionY = MaxY;
                }
            }
 
            TaskPosition taskPosition = new TaskPosition()
            {
                PositionR = 1,
                TakePositionX = takePositionX,
                TakePositionY = takePositionY,
                TakePositionZ = takePositionZ,
                PutPositionX = putPositionX,
                PutPositionY = putPositionY,
                PutPositionZ = putPositionZ,
                TakeCenterPositionX = takePositionX,
                TakeCenterPositionY = takePositionY,
                TakeCenterPositionZ = takePositionZ,
                PutCenterPositionX = putPositionX,
                PutCenterPositionY = putPositionY,
                PutCenterPositionZ = putPositionZ,
                PositionX = putPositionX,
                PositionY = putPositionY,
                PositionZ = putPositionZ
            };
 
            return taskPosition;
        }
    }
}