| | |
| | | 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") |
| | | area1 = "4"; |
| | | |
| | | #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(); |
| | | //} |
| | | #endregion |
| | | |
| | | inventory = inventoryRepository.Find(x => x.FigureNumber == stationinfo.stationType).OrderByDescending(x => x.OnlineTime).FirstOrDefault(); |
| | | #endregion |
| | | |
| | | dt_stationinfo TargetLocation = null; |
| | |
| | | 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; |
| | | } |
| | | //} |
| | | 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(); |
| | | 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 (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 (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(); |
| | | |
| | | 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) |
| | |
| | | return TargetLocation; |
| | | } |
| | | } |
| | | //if (TargetLocation != null) return TargetLocation; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | { |
| | | 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.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 |
| | | |
| | | #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(); |
| | | if (TargetLocation == null && area != "4") |
| | |
| | | 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) |