| | |
| | | public class StationTask |
| | | { |
| | | |
| | | FreeDB freeDB = new FreeDB(); |
| | | public void CreateTask() |
| | | static FreeDB freeDB = new FreeDB(); |
| | | public static void CreateTask() |
| | | { |
| | | VOLContext context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | |
| | | //æ ¹æ®ä¸æå£çç»å®ä¿¡æ¯æ¥è¯¢å¯¹åºå·¥åï¼æ£æµæ¤å·¥åæ¯å¦å·²å®æ 宿å³å¯å°å
¶éå
¥åº |
| | | |
| | | dt_mes_head mesinfo = freeDB.Select<dt_mes_head>().Where(x => x.jobID == item.Number).First(); |
| | | dt_geometry_data dt_Geometry_Data = freeDB.Select<dt_geometry_data>().Where(x => x.Description == mesinfo.drawingNo).First(); |
| | | int CompeletedNum = Convert.ToInt32(mesinfo.quantity) - Convert.ToInt32(mesinfo.finishNum); |
| | | |
| | | |
| | | //å¤å®ä»»å¡æ¯å¦å·²å建//å¦å·²åå¨ |
| | | if (freeDB.Select<dt_agvtask>().Where(x => x.agv_fromaddress == item.stationCode).Count() > 0) |
| | |
| | | |
| | | if (item.quantity == 5 || CompeletedNum == 0) //循ç¯è¯»å车轮æ°ä¸º5æè
订å已宿æ°éçä¸æå£ âå·¥å人工å
³éçå·¥å |
| | | { |
| | | if (mesinfo.quantity <= 50) //å°äº50ä»¶ç´æ¥åºåº |
| | | |
| | | |
| | | if (mesinfo.quantity <= 50 || item.stationCode.Contains("3")) //å°äº50ä»¶ç´æ¥åºåº |
| | | { |
| | | //var station = |
| | | //todo 寻æ¾å¯æ¾è´§å¤åæ¾è´§å° |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository, mesinfo, item); |
| | | dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository, mesinfo, item, CompeletedNum, dt_Geometry_Data.e); |
| | | |
| | | if (TargetLocation != null) |
| | | { |
| | |
| | | /// <param name="workinfo">订å</param> |
| | | /// <param name="stationinfo">䏿å£ä¿¡æ¯</param> |
| | | /// <returns></returns> |
| | | private dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, dt_mes_head mesinfo, dt_stationinfo stationinfo) |
| | | private static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository, dt_mes_head mesinfo, dt_stationinfo stationinfo, int CompeletedNum, float e) |
| | | { |
| | | //æ¾è´§ä½ |
| | | dt_stationinfo TargetLocation = null; |
| | | |
| | | |
| | | #region æ ¹æ®è®¢åæ°éæ¥å¯»æ¾å¯¹åºåºåºä¸åç©æç±»ååºä½ |
| | | //if (workinfo.PlannedQuantity < 50) //åºåº1 ç©æç±»åå¤ |
| | |
| | | //} |
| | | #endregion |
| | | |
| | | //æ ¹æ®è®¢åçå·/å·¥åå·/ç±»å |
| | | if (mesinfo.quantity >= 180) |
| | | var detail = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mesinfo.jobID).First(); |
| | | dt_inventory inventory = null; |
| | | if (detail.heatID != null) |
| | | { |
| | | //æ¥è¯¢åºåè®°å½ä¸æ¯å¦åå¨åç±»å/å·¥å/çå·çè®°å½ å¦æåæ¾ç½®åä¸è¡ï¼æ åå¯»æ¾æ°åºä½ |
| | | var detail = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mesinfo.jobID).First(); |
| | | var inventory = freeDB.Select<dt_inventory>().Where(x => x.HeatNumber == detail.heatID /*&& x.*/).First(); |
| | | if (inventory != null) |
| | | inventory = freeDB.Select<dt_inventory>().Where(x => x.HeatNumber == detail.heatID && x.FigureNumber == mesinfo.drawingNo && x.jobID == mesinfo.jobID).First(); |
| | | } |
| | | else |
| | | { |
| | | inventory = freeDB.Select<dt_inventory>().Where(x => x.FigureNumber == mesinfo.drawingNo && x.jobID == mesinfo.jobID).First(); |
| | | } |
| | | |
| | | if (inventory != null) |
| | | { |
| | | var station = stationinfoRepository.FindFirst(x => x.stationCode == inventory.stationCode); |
| | | if (CompeletedNum <= 15 || station.area == "1") |
| | | { |
| | | int line = Convert.ToInt16(inventory.stationCode.Split("-")[0]); |
| | | TargetLocation = stationinfoRepository.Find(x => x.line == line && x.location_state == LocationStateEnum.Empty.ToString() && x.area == inventory.area).FirstOrDefault(); |
| | | TargetLocation = stationinfoRepository.Find(x => x.column == station.column && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.area).OrderBy(x => x.line).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.area == "2" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | 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) return TargetLocation; |
| | | } |
| | | |
| | | if (CompeletedNum <= 15) |
| | | { |
| | | TargetLocation = stationinfoRepository.Find(x => x.line == 1 && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == "1").OrderBy(x => x.column).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | //if (50 < mesinfo.quantity && mesinfo.quantity <= 180 && e < 1100) |
| | | // TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == "2" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault(); |
| | | //else if (180 < mesinfo.quantity && mesinfo.quantity <= 225 && e < 1100) |
| | | // TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == "3" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault(); |
| | | //if (50 < mesinfo.quantity && e > 1100 || TargetLocation == null) |
| | | var area = GetArea(mesinfo.quantity, e); |
| | | TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault(); |
| | | if (TargetLocation == null) |
| | | TargetLocation = stationinfoRepository.Find(x => x.column == 1 && x.area == "4" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).FirstOrDefault(); |
| | | } |
| | | |
| | | #region |
| | | |
| | | //æ ¹æ®è®¢åçå·/å·¥åå·/ç±»å |
| | | //if (mesinfo.quantity >= 180) |
| | | //{ |
| | | // //æ¥è¯¢åºåè®°å½ä¸æ¯å¦åå¨åç±»å/å·¥å/çå·çè®°å½ å¦æåæ¾ç½®åä¸è¡ï¼æ åå¯»æ¾æ°åºä½ |
| | | // var detail = freeDB.Select<dt_mes_detail>().Where(x => x.jobID == mesinfo.jobID).First(); |
| | | // var inventory = freeDB.Select<dt_inventory>().Where(x => x.HeatNumber == detail.heatID && x.FigureNumber == mesinfo.drawingNo && x.jobID == mesinfo.jobID).First(); |
| | | // if (inventory != null) |
| | | // { |
| | | // //int line = Convert.ToInt16(inventory.stationCode.Split("-")[0]); |
| | | // var line = stationinfoRepository.FindFirst(x => x.stationCode == inventory.stationCode).line; |
| | | // TargetLocation = stationinfoRepository.Find(x => x.line == line && x.location_state == LocationStateEnum.Empty.ToString() && x.enable && x.area == inventory.area).OrderBy(x => x.column).FirstOrDefault(); |
| | | // if (TargetLocation == null && CompeletedNum <= 15) |
| | | // { |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == "1" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // TargetLocation = stationinfoRepository.Find(x => x.area == "2" && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderBy(x => x.line).ThenBy(x => x.column).FirstOrDefault(); |
| | | |
| | | // } |
| | | //} |
| | | #endregion |
| | | |
| | | if (TargetLocation == null) |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="quantity"></param> |
| | | /// <returns></returns> |
| | | private string GetArea(int quantity) |
| | | private static string GetArea(int quantity, float e) |
| | | { |
| | | if (quantity >= 50 && quantity < 180) |
| | | return "2"; |
| | | else if (quantity >= 180 && quantity < 180) |
| | | return "3"; |
| | | else if (quantity >= 180 && quantity < 220) |
| | | if (e < 1100) |
| | | { |
| | | if (quantity <= 180) |
| | | return "2"; |
| | | else if (quantity <= 225) |
| | | return "3"; |
| | | } |
| | | else |
| | | { |
| | | return "4"; |
| | | } |
| | | |
| | | //if (quantity > 50 && quantity <= 180 && e < 1100) |
| | | // return "2"; |
| | | //else if (quantity > 180 && quantity <= 225 && e < 1100) |
| | | // return "3"; |
| | | //else if (quantity > 50 && e > 1100) |
| | | // return "4"; |
| | | return null; |
| | | } |
| | | } |