From 6e7f192546903b04d2d37e852dd9b248e938c790 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期五, 01 八月 2025 09:23:17 +0800
Subject: [PATCH] 1
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/PlaceBlockService.cs | 113 ++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 80 insertions(+), 33 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/PlaceBlockService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/PlaceBlockService.cs"
index d214f45..1bef58e 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/PlaceBlockService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/PlaceBlockService.cs"
@@ -29,6 +29,8 @@
/// </remarks>
public class PlaceBlockService
{
+ //613 526
+
/// <summary>
/// 鑾峰彇閰嶇疆鏂囦欢涓�"Spacing"閿搴旂殑鏁存暟鍊硷紝琛ㄧず闂磋窛鍊�
/// </summary>
@@ -38,6 +40,16 @@
/// 鑾峰彇鎴栬缃渶澶ф棆杞暱搴﹂厤缃��
/// </summary>
public static int MaxRotateLength = AppSettings.GetValue("MaxRotateLength").ObjToInt();
+
+ /// <summary>
+ /// 鏈�灏忓搴鍋忕Щ閲忥紙姣背锛�
+ /// </summary>
+ public static int MinWidthOffset = AppSettings.GetValue("MinWidthOffset").ObjToInt();
+
+ /// <summary>
+ /// 鏈�澶у搴鍋忕Щ閲忥紙姣背锛�
+ /// </summary>
+ public static int MaxWidthOffset = AppSettings.GetValue("MaxWidthOffset").ObjToInt();
/// <summary>
/// 鏈�澶鍧愭爣闄愬埗锛堟绫筹級
@@ -330,12 +342,14 @@
var candidate = new Point3D(x, y, baseZ);
if (IsPositionValid(candidate, l, w, h))
{
- TaskPosition taskPosition = GetTaskPosition(candidate, l, w, h, edge);
- if (IsPositionValid(taskPosition))
+ TaskPosition? taskPosition = GetTaskPosition(candidate, l, w, h, edge);
+ if (taskPosition != null)
{
- return taskPosition;
+ if (IsPositionValid(taskPosition))
+ {
+ return taskPosition;
+ }
}
-
}
}
}
@@ -447,6 +461,10 @@
/// <returns>濡傛灉Y杞村潗鏍囧湪鏈夋晥鑼冨洿鍐呰繑鍥瀟rue锛屽惁鍒欒繑鍥瀎alse</returns>
private bool IsPositionValid(TaskPosition pos)
{
+ if (pos.Edge == 1 && pos.PutPositionX > 70 || pos.Edge == 2 && pos.PutPositionX < 0)
+ {
+ return false;
+ }
return pos.PutPositionY <= MaxY && pos.PutPositionY >= 0 && pos.TakePositionY >= 0;
}
@@ -464,7 +482,7 @@
/// 骞惰绠楀惛鐩樹腑蹇冪偣浣嶇疆锛屽悓鏃跺鐞嗚竟鐣屾潯浠堕檺鍒躲��
/// 妯悜鏀剧疆鏃舵渶灏廦鍧愭爣涓�155锛岀旱鍚戞椂涓�350锛屾渶澶鍧愭爣涓�700銆�
/// </remarks>
- public TaskPosition GetTaskPosition(Point3D point3D, int length, int width, int height, int edge)
+ public TaskPosition? GetTaskPosition(Point3D point3D, int length, int width, int height, int edge)
{
//鏀捐揣浣嶇疆鏉挎潗涓績鐐�
Point3D putCenter = new Point3D(point3D.X + length / 2, point3D.Y + width / 2, point3D.Z + height / 2);
@@ -481,6 +499,13 @@
int putPositionX = 0;
int putPositionY = 0;
int putPositionZ = 0;
+
+ int takeCenterX = 0;
+ int takeCenterY = 0;
+ int takeCenterZ = 0;
+ int putCenterX = 0;
+ int putCenterY = 0;
+ int putCenterZ = 0;
//1.濡傛灉闀垮害澶т簬920锛屽搴﹀ぇ浜庣瓑浜�300锛屽垯鍙互浣跨敤鍙屽惛鐩樻í鍚戝惛鍙�
if (length > 920) //妯悜鍙屽惛
@@ -511,6 +536,13 @@
putPositionY = (putCenter.X - deviceCenter.Y);
putPositionZ = point3D.Z;
}
+
+ takeCenterX = takePositionX;
+ takeCenterY = takePositionY;
+ takeCenterZ = takePositionZ;
+ putCenterX = putPositionX;
+ putCenterY = putPositionY;
+ putCenterZ = putPositionZ;
if (takePositionY <= MinY)
{
@@ -549,35 +581,43 @@
}
}
- if (positionR == 2 && edge == 0)
+ if (width > MinWidthOffset && width < MaxWidthOffset)
{
- takePositionX = width - 530;
- putPositionX = point3D.Y;
+ takePositionX = takeCenterX;
+ putPositionX = putCenterX;
}
- else if (positionR == 2 && edge == 1)
+ else
{
- takePositionX = 0;
- putPositionX = point3D.Y + width - 530;
- }
- else if (positionR == 1 && edge == 1)
- {
- if(width > ContainerSize.Width)
- {
- takePositionX = 0;
- putPositionX = point3D.Y;
- }
- else
+ if (positionR == 2 && edge == 0)
{
takePositionX = width - 530;
- putPositionX = point3D.Y + (width - 530);
+ putPositionX = point3D.Y;
}
- }
- else if (positionR == 1 && edge == 0)
- {
- if (putPositionX < 0)
+ else if (positionR == 2 && edge == 1)
{
takePositionX = 0;
- putPositionX = point3D.Y;
+ putPositionX = point3D.Y + width - 530;
+ }
+ else if (positionR == 1 && edge == 1)
+ {
+ if (width > ContainerSize.Width)
+ {
+ takePositionX = 0;
+ putPositionX = point3D.Y;
+ }
+ else
+ {
+ takePositionX = width - 530;
+ putPositionX = point3D.Y + (width - 530);
+ }
+ }
+ else if (positionR == 1 && edge == 0)
+ {
+ if (putPositionX < 0)
+ {
+ takePositionX = 0;
+ putPositionX = point3D.Y;
+ }
}
}
@@ -595,17 +635,24 @@
PutPositionX = putPositionX,
PutPositionY = putPositionY,
PutPositionZ = putPositionZ,
- TakeCenterPositionX = takeCenter.X,
- TakeCenterPositionY = takeCenter.Y,
- TakeCenterPositionZ = takeCenter.Z,
- PutCenterPositionX = putCenter.X,
- PutCenterPositionY = putCenter.Y,
- PutCenterPositionZ = putCenter.Z,
+ TakeCenterPositionX = takeCenterX,
+ TakeCenterPositionY = takeCenterY,
+ TakeCenterPositionZ = takeCenterZ,
+ PutCenterPositionX = putCenterX,
+ PutCenterPositionY = putCenterY,
+ PutCenterPositionZ = putCenterZ,
PositionX = point3D.X,
PositionY = point3D.Y,
- PositionZ = point3D.Z
+ PositionZ = point3D.Z,
+ Edge = edge,
};
+
+ if (!IsPositionValid(taskPosition))
+ {
+ return null;
+ }
+
return taskPosition;
}
}
--
Gitblit v1.9.3