From 76eef0389848065963a295c66163a630697054fa Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期日, 07 七月 2024 09:47:01 +0800
Subject: [PATCH] PDA
---
代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/新文件夹/GetLocation.cs | 245 +++++++++++++++++--------------------------------
1 files changed, 85 insertions(+), 160 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
index 9365f38..969cf14 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/GetLocation.cs"
@@ -24,207 +24,134 @@
/// <param name="mesinfo"></param>
/// <param name="stationinfo"></param>
/// <returns></returns>
- public static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, VV_Mes_Workinfo mesinfo, dt_stationinfo stationinfo)
+ public static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, VV_Mes_Workinfo mesinfo, dt_agvtask agvtask)
{
lock (GetEmptyLocationobj)
{
try
{
VOLContext context = new VOLContext();
- //Idt_mes_detailRepository mes_DetailRepository = new dt_mes_detailRepository(context);
Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
- //var detail = mes_DetailRepository.Find(x => x.jobID == mesinfo.jobID).FirstOrDefault();
- //if (detail == null)
- //{
- // stationinfo.remark = "瑙﹀彂鍏ュ簱浠诲姟,浣嗘湭鎵惧埌宸ュ崟瀛愯〃锛�";
- // stationinfo.location_state = LocationStateEnum.Abnormal.ToString();
- // stationinfoRepository.Update(stationinfo, true);
- // return null;
- //}
string area1 = "";
- if (stationinfo.tray_type == "LargeTray")
+ if (agvtask.agv_Traytype == "LargeTray")
area1 = "4";
+
+ dt_stationinfo TargetLocation = null;
+
+ #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
+ //TargetLocation = area1 == "4" ? stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && x.enable && x.area == area1).FirstOrDefault() : stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "2" || x.area == "3") && x.enable).FirstOrDefault();
+ TargetLocation = area1 == "4" ? stationinfoRepository.Find(x => x.Number == agvtask.jobID && x.location_state == LocationStateEnum.InBusy.ToString() && x.enable && x.area == area1).FirstOrDefault() : stationinfoRepository.Find(x => x.Number == agvtask.jobID && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "2" || x.area == "3") && x.enable).FirstOrDefault();
+ if (TargetLocation != null)
+ {
+ TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
+ if (TargetLocation != null)
+ if (!GetStation.OutBusyStation(TargetLocation.stationCode) && !GetStation.QueueStation(TargetLocation.stationCode)) return TargetLocation;
+ }
+ #endregion
#region 鏌ユ壘搴撳瓨
dt_inventory inventory = null;
- inventory = inventoryRepository.Find(x => x.FigureNumber == mesinfo.drawingNo).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
-
- #region 鏍规嵁鏉′欢鏌ヨ搴撳瓨
- //if (mesinfo.heatID != null)
- //{
- // inventory = inventoryRepository.Find(x => x.HeatNumber == mesinfo.heatID && x.FigureNumber == mesinfo.drawingNo && x.jobID == mesinfo.workOrder).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
- //}
- //else
- //{
- // inventory = inventoryRepository.Find(x => x.FigureNumber == mesinfo.drawingNo && x.jobID == mesinfo.workOrder).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
- //}
+ //inventory = area1 == "4" ? inventoryRepository.Find(x => x.FigureNumber == agvtask.agv_materielid && x.area == area1).OrderByDescending(x => x.OnlineTime).FirstOrDefault()
+ // : inventoryRepository.Find(x => x.FigureNumber == agvtask.agv_materielid && (x.area == "2" || x.area == "3")).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
+ inventory = area1 == "4" ? inventoryRepository.Find(x => x.workOrder == agvtask.jobID && x.area == area1).OrderByDescending(x => x.OnlineTime).FirstOrDefault()
+ : inventoryRepository.Find(x => x.FigureNumber == agvtask.agv_materielid && (x.area == "2" || x.area == "3")).OrderByDescending(x => x.OnlineTime).FirstOrDefault();
#endregion
- #endregion
-
- dt_stationinfo TargetLocation = null;
#region 鏍规嵁搴撳瓨鏌ユ壘鍙叆搴撶┖璐т綅
if (inventory != null)
{
var station = stationinfoRepository.FindFirst(x => x.stationCode == inventory.stationCode);
- if (!string.IsNullOrEmpty(area1) && station.area != area1)//鍏ュぇ鎵樼洏搴撳尯
+
+ #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
+ //TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == station.area).FirstOrDefault();
+ //if (TargetLocation != null)
+ //{
+ // TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
+ // if (TargetLocation != null)
+ // {
+ // if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+ // return TargetLocation;
+ // }
+ //}
+ #endregion
+
+ #region 鍒ゆ柇褰撳墠琛屾槸鍚﹁繕鏈夌┖璐т綅
+ TargetLocation = stationinfoRepository.Find(x => x.line == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == station.area).OrderBy(x => x.column).FirstOrDefault();
+ if (TargetLocation != null)
{
- #region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
- TargetLocation = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.InBusy.ToString() && x.area == area1).FirstOrDefault();
- if (TargetLocation != null)
- {
- //if (TargetLocation.area == "1")
- //{
- // //TargetLocation = stationinfoRepository.Find(x => x.column == TargetLocation.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderByDescending(x => x.line).FirstOrDefault();
-
- // TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();//鎸夎瀛樻斁
-
- // if (TargetLocation != null)
- // {
- // if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
- // return TargetLocation;
- // }
- //}
- //else
- //{
- TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
- if (TargetLocation != null)
- {
- if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
- return TargetLocation;
- }
- //}
- }
- #endregion
-
- #region 瀵绘壘绌鸿揣浣�
- var TargetLocations1 = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == area1).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
- foreach (var Location in TargetLocations1)
- {
- //if (Location.area == "1")
- //{
- // if (stationinfoRepository.Find(x => x.column == Location.column && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
- //}
- //else
- //{
- if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
- //}
- }
- //if (TargetLocation != null)
- //{
- // if (stationinfoRepository.Find(x => x.line == TargetLocation.line && x.column == 1 && x.stationType == stationinfo.stationType).Any()) return TargetLocation;
- //}
- #endregion
-
-
+ if (!GetStation.OutBusyStation(TargetLocation.stationCode) && !GetStation.QueueStation(TargetLocation.stationCode))
+ return TargetLocation;
}
- if (station.area == "1")
- {
- //TargetLocation = stationinfoRepository.Find(x => x.column == station.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.area).OrderByDescending(x => x.line).FirstOrDefault();
+ #endregion
- TargetLocation = stationinfoRepository.Find(x => x.line == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == station.area).OrderBy(x => x.column).FirstOrDefault();//鎸夎瀛樻斁
+ #region 瀵绘壘绌鸿揣浣�
+ //var TargetLocations1 = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == station.area).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
+ //foreach (var Location in TargetLocations1)
+ //{
+ // if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == agvtask.agv_materielid).Any())
+ // if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any()) return Location;
+ //}
+ #endregion
- if (TargetLocation != null)
- {
- if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
- return TargetLocation;
- }
- }
- else
- {
- TargetLocation = stationinfoRepository.Find(x => x.line == station.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.area).OrderBy(x => x.column).FirstOrDefault();
- if (TargetLocation != null)
- {
- if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
- return TargetLocation;
- }
- }
- //if (TargetLocation != null) return TargetLocation;
}
#endregion
#region 瀵绘壘宸插垎閰嶅悓鍥惧彿鍏ュ簱浠诲姟搴撲綅
- TargetLocation = stationinfoRepository.Find(x => x.stationType == stationinfo.stationType && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).FirstOrDefault();
- if (TargetLocation != null)
- {
- if (TargetLocation.area == "1")
- {
- //TargetLocation = stationinfoRepository.Find(x => x.column == TargetLocation.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderByDescending(x => x.line).FirstOrDefault();
-
- TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();//鎸夎瀛樻斁
-
- if (TargetLocation != null)
- {
- if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
- return TargetLocation;
- }
- }
- else
- {
- TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
- if (TargetLocation != null)
- {
- if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
- return TargetLocation;
- }
- }
- }
- #endregion
-
- #region 瀵绘壘绌鸿揣浣�
- var TargetLocations = stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
- foreach (var Location in TargetLocations)
- {
- if (Location.area == "1")
- {
- if (stationinfoRepository.Find(x => x.column == Location.column && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
- }
- else
- {
- if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.stationType == stationinfo.stationType && x.location_state != LocationStateEnum.OutBusy.ToString()).Any()) return Location;
- }
- }
+ //TargetLocation = stationinfoRepository.Find(x => x.stationType == agvtask.agv_materielid && x.location_state == LocationStateEnum.InBusy.ToString() && (x.area == "1" || x.area == "2" || x.area == "3" || x.area == "4")).FirstOrDefault();
//if (TargetLocation != null)
//{
- // if (stationinfoRepository.Find(x => x.line == TargetLocation.line && x.column == 1 && x.stationType == stationinfo.stationType).Any()) return TargetLocation;
+ // if (TargetLocation.area == "1")
+ // {
+ // TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();//鎸夎瀛樻斁
+
+ // if (TargetLocation != null)
+ // {
+ // if (!stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area /*&& x.enable*/ && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+ // return TargetLocation;
+ // }
+ // }
+ // else
+ // {
+ // TargetLocation = stationinfoRepository.Find(x => x.line == TargetLocation.line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == TargetLocation.area).OrderBy(x => x.column).FirstOrDefault();
+ // if (TargetLocation != null)
+ // {
+ // if (!stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any())
+ // return TargetLocation;
+ // }
+ // }
//}
#endregion
#region 鏈壘鍒板簱瀛樻垨褰撳墠搴撳瓨琛屽凡婊�,瀵绘壘鏂扮殑涓�琛�
- //var area1 = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, e) : mesinfo.area;(area == "2" ? 1 : 10)
- //var area = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, stationinfo.tray_type) : mesinfo.area;
- var area = GetArea(mesinfo.quantity, stationinfo.tray_type);
- TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
+ var area = GetArea(mesinfo.quantity, agvtask.agv_Traytype);
+ TargetLocation = stationinfoRepository.Find(x => x.column == (area == "2" ? 1 : 2) && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault();
if (TargetLocation == null && area != "4")
{
- if (area == "2")
- area = "3";
- else if (area == "3")
- area = "2";
- TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
- if (TargetLocation == null)
- TargetLocation = stationinfoRepository.Find(x => x.line == 2 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).FirstOrDefault();
+ area = area == "2" ? "3" : "2";
+ TargetLocation = stationinfoRepository.Find(x => x.column == (area == "2" ? 1 : 2) && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault();
}
#region 鏌ョ湅褰撳墠绌鸿揣浣嶅悗鏄惁瀛樺湪鏈夋枡
if (TargetLocation != null)
+ //if (GetStation.QueueStation(TargetLocation.stationCode)) TargetLocation = null;
+ if (!GetStation.QueueStation(TargetLocation.stationCode)) return TargetLocation;
+ #endregion
+
+ #endregion
+
+ #region 瀵绘壘瀵瑰簲搴撳尯绌鸿揣浣�
+
+ var TargetLocations = area1 == "4" ? stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "4").OrderBy(x => x.line).ThenBy(x => x.column).ToList()
+ : stationinfoRepository.Find(x => x.location_state == LocationStateEnum.Empty.ToString() && x.enable && (x.area == "2" || x.area == "3")).OrderBy(x => x.line).ThenBy(x => x.column).ToList();
+ foreach (var Location in TargetLocations)
{
- if (TargetLocation.area == "1")
- {
- //绗竴琛屼笉涓虹┖璐т綅鍒欎笉鑳芥斁缃浜岃
- if (stationinfoRepository.Find(x => x.column == TargetLocation.column && x.area == TargetLocation.area && x.location_state != LocationStateEnum.Empty.ToString() && x.line == 1).Any()) TargetLocation = null;
- }
- else
- {
- if (stationinfoRepository.Find(x => x.line == TargetLocation.line && x.area == TargetLocation.area && x.location_state != LocationStateEnum.Empty.ToString()).Any()) TargetLocation = null;
- }
+ if (stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.Number == agvtask.jobID).Any())
+ if (!stationinfoRepository.Find(x => x.line == Location.line && x.area == Location.area && x.location_state == LocationStateEnum.OutBusy.ToString()).Any() && !GetStation.QueueStation(Location.stationCode)) return Location;
}
#endregion
- #endregion
-
- if (TargetLocation == null) throw new Exception("搴撲綅宸叉弧");
+ //if (TargetLocation == null) throw new Exception("搴撲綅宸叉弧");
return TargetLocation;
}
catch (Exception ex)
@@ -297,12 +224,10 @@
return TargetLocation;
}
}
- //if (TargetLocation != null) return TargetLocation;
}
#endregion
#region 鏈壘鍒板簱瀛樻垨褰撳墠搴撳瓨琛屽凡婊�,瀵绘壘鏂扮殑涓�琛�
- //var area1 = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, e) : mesinfo.area;
var area = string.IsNullOrEmpty(mesinfo.area) ? GetArea(mesinfo.quantity, stationinfo.tray_type) : mesinfo.area;
TargetLocation = stationinfoRepository.Find(x => x.column == (area == "2" ? 1 : 10) && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault();
if (TargetLocation == null)
--
Gitblit v1.9.3