| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Comm; |
| | | using WIDESEA_Comm.LogInfo; |
| | | using WIDESEA_Comm.TaskNo; |
| | | using WIDESEA_Core.FreeDB; |
| | | using WIDESEA_Common; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_Entity.DomainModels; |
| | | using WIDESEA_WCS.JobsPart.Common.åå¨è¿ç¨; |
| | | using WIDESEA_WCS.IRepositories; |
| | | using WIDESEA_WCS.Repositories; |
| | | using WIDESEA_WMS.IRepositories; |
| | | using WIDESEA_WMS.Repositories; |
| | | using static FreeSql.Internal.GlobalFilter; |
| | | using static System.Collections.Specialized.BitVector32; |
| | | |
| | |
| | | { |
| | | public class ReplaceTray |
| | | { |
| | | static FreeDB freeDB = new FreeDB(); |
| | | #region MyRegion |
| | | //public static void a() |
| | | //{ |
| | | // FreeDB freeDB = new FreeDB(); |
| | | // var mes_Detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == "1202956016").First(); |
| | | // var mes_Head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == mes_Detail.jobID).First(); |
| | | |
| | | public static void a() |
| | | { |
| | | var mes_Detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == "1202956016").First(); |
| | | var mes_Head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == mes_Detail.jobID).First(); |
| | | // dt_inventory inventory = new dt_inventory() |
| | | // { |
| | | // SN = mes_Detail.SN, |
| | | // Name = mes_Head.productName, |
| | | // FigureNumber = mes_Head.drawingNo, |
| | | // area = "2", |
| | | // HeatNumber = mes_Detail.heatID, |
| | | // BilletNumber = mes_Detail.billetID, |
| | | // OnlineTime = DateTime.Now, |
| | | // Operator = "AGV", |
| | | // stationCode = "B01001001", |
| | | // jobID = mes_Detail.jobID, |
| | | // ID = Guid.NewGuid(), |
| | | // remark = "" |
| | | // }; |
| | | // StoredProcedure.Main(inventory, "Delete"); |
| | | // //StoredProcedure.EXECAdd(inventory, ""); |
| | | //} |
| | | #endregion |
| | | |
| | | dt_inventory inventory = new dt_inventory() |
| | | { |
| | | SN = mes_Detail.SN, |
| | | Name = mes_Head.productName, |
| | | FigureNumber = mes_Head.drawingNo, |
| | | area = "2", |
| | | HeatNumber = mes_Detail.heatID, |
| | | BilletNumber = mes_Detail.billetID, |
| | | OnlineTime = DateTime.Now, |
| | | Operator = "AGV", |
| | | stationCode = "B01001001", |
| | | jobID = mes_Detail.jobID, |
| | | ID = Guid.NewGuid(), |
| | | remark="" |
| | | }; |
| | | StoredProcedure.EXEC( inventory,""); |
| | | } |
| | | /// <summary> |
| | | /// åå»ºæ´æ¢æçä»»å¡ |
| | | /// åå»ºæ´æ¢æçä»»å¡,éä¿®æ¹ |
| | | /// </summary> |
| | | public static void ReplaceTrayTask() |
| | | { |
| | | try |
| | | { |
| | | var stations = freeDB.Select<dt_stationinfo>().Where(x => x.stationCode.Contains("X") && x.location_state == LocationStateEnum.Abnormal.ToString() && (x.tray_type == "SmallTray/LargeTray" || x.tray_type == "LargeTray/SmallTray")).ToList(); |
| | | VOLContext context = new VOLContext(); |
| | | Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context); |
| | | Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);//"Abnormal" |
| | | var stations = stationinfoRepository.Find(x => (x.stationCode.Contains("X") || x.stationCode.Contains("W01001004") || x.stationCode.Contains("W01001005")) && x.location_state == LocationStateEnum.Trayswitching.ToString() && x.enable).ToList(); |
| | | foreach (var station in stations) |
| | | { |
| | | if (agvtaskRepository.Find(x => x.agv_fromaddress == station.stationCode || x.agv_toaddress == station.stationCode).Any()) continue; |
| | | #region MyRegion |
| | | var types = station.tray_type.Split('/'); |
| | | var area = types[0] == "SmallTray" ? "11" : "10"; |
| | | //æ¾1åºåºç空æä½ |
| | | |
| | | var EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("A") && x.location_state == "Empty" && x.enable) |
| | | .OrderBy(x => x.column).OrderByDescending(x => x.line).First(); |
| | | if (EmptyStation == null) |
| | | EmptyStation = freeDB.Select<dt_stationinfo>().Where(x => x.area == area && x.stationCode.Contains("C") && x.location_state == "Empty" && x.enable) |
| | | .OrderBy(x => x.line).OrderBy(x => x.column).First(); |
| | | if (EmptyStation != null) |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 2, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Create", |
| | | //agv_materielid = station.stationType, |
| | | agv_qty = 1, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = EmptyStation.stationCode, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = station.tray_status, |
| | | //bindSN = station.bindSN, |
| | | //agv_worktype = Convert.ToInt32(mesinfo.processCode), |
| | | //agv_materbarcode = mesinfo.materialCode, |
| | | agv_Traytype = types[0] |
| | | }; |
| | | freeDB.Add(agvtask); |
| | | CreatePartQueue(agvtask, types[1]); |
| | | } |
| | | agv_fromaddress = station.stationCode, |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | agv_grade = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = AGVTaskStateEnum.Queue.ToString(), |
| | | agv_qty = 1, |
| | | StarQuantity = 0, |
| | | EndQuantity = 0,//EmptyStation.quantity, |
| | | agv_tasktype = AGVTaskTypeEnum.TaskType_EmptyPallet.ToString(), |
| | | agv_toaddress = "",//EmptyStation.stationCode, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = station.tray_status, |
| | | agv_Traytype = types[0] |
| | | }; |
| | | agvtaskRepository.Add(agvtask, true); |
| | | station.location_state = LocationStateEnum.Busy.ToString(); |
| | | stationinfoRepository.Update(station, true); |
| | | WriteDBLog.Success("åå»ºæ´æ¢ç©ºçä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}", "PCS"); |
| | | CreatePartQueue(agvtaskRepository, agvtask, agvtask.agv_Traytype == "SmallTray" ? "LargeTray" : "SmallTray"); |
| | | #endregion |
| | | |
| | | #region MyRegion |
| | | //var types = station.tray_type.Split('/'); |
| | | //var area = types[0] == "SmallTray" ? "11" : "10"; |
| | | ////æ¾1åºåºç空æä½ |
| | | //var EmptyStation = GetStation.EmptyPalletStation(area); |
| | | //if (EmptyStation != null) |
| | | //{ |
| | | // dt_agvtask agvtask = new dt_agvtask() |
| | | // { |
| | | // agv_fromaddress = station.stationCode, |
| | | // agv_id = Guid.NewGuid(), |
| | | // agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), |
| | | // agv_grade = 2, |
| | | // agv_createtime = DateTime.Now, |
| | | // agv_taskstate = "Create", |
| | | // agv_qty = 1, |
| | | // StarQuantity = 0, |
| | | // EndQuantity = EmptyStation.quantity, |
| | | // agv_tasktype = "TaskType_EmptyPallet", |
| | | // agv_toaddress = EmptyStation.stationCode, |
| | | // agv_userid = "ç³»ç»", |
| | | // agv_TrayStatus = station.tray_status, |
| | | // agv_Traytype = types[0] |
| | | // }; |
| | | // agvtaskRepository.Add(agvtask, true); |
| | | // station.location_state = LocationStateEnum.Busy.ToString(); |
| | | // stationinfoRepository.Update(station, true); |
| | | // EmptyStation.location_state = LocationStateEnum.Busy.ToString(); |
| | | // stationinfoRepository.Update(EmptyStation, true); |
| | | // WriteDBLog.Success("åå»ºæ´æ¢ç©ºçä»»å¡", $"ä»»å¡ç¼å·ï¼{agvtask.agv_tasknum}", "PCS"); |
| | | // CreatePartQueue(agvtaskRepository, agvtask, agvtask.agv_Traytype == "SmallTray" ? "LargeTray" : "SmallTray"); |
| | | //} |
| | | #endregion |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | throw; |
| | | WriteDBLog.Error("åå»ºæ´æ¢ç©ºçä»»å¡", $"é误信æ¯ï¼{ex.Message}", "PCS"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// åå»ºå®æ´ç补空æä»»å¡ |
| | | /// </summary> |
| | | /// <param name="agvtask"></param> |
| | | public static void CreatePartQueue(dt_agvtask agvtask, string type = "") |
| | | public static void CreatePartQueue(Idt_agvtaskRepository agvtaskRepository, dt_agvtask agvtask, string type = "") |
| | | { |
| | | if (agvtask.agv_fromaddress.Contains("X")) |
| | | //if (agvtask.agv_fromaddress.Contains("X") || agvtask.agv_fromaddress.Contains("W01001004") || agvtask.agv_fromaddress.Contains("W01001005")) |
| | | //{ |
| | | dt_agvtask taskPart = new dt_agvtask() |
| | | { |
| | | dt_agvtask taskPart = new dt_agvtask() |
| | | { |
| | | agv_fromaddress = "", |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = agvtask.agv_tasknum + "_1", |
| | | agv_grade = 2, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | agv_qty = 1, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = agvtask.agv_fromaddress, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = agvtask.agv_TrayStatus, |
| | | agv_Traytype = type |
| | | }; |
| | | freeDB.Add(taskPart); |
| | | } |
| | | agv_fromaddress = "", |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = agvtask.agv_tasknum + "_1", |
| | | agv_grade = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_taskstate = "Queue", |
| | | agv_qty = 1, |
| | | agv_tasktype = "TaskType_EmptyPallet", |
| | | agv_toaddress = agvtask.agv_fromaddress, |
| | | agv_userid = "ç³»ç»", |
| | | agv_TrayStatus = agvtask.agv_TrayStatus, |
| | | agv_Traytype = type, |
| | | }; |
| | | agvtaskRepository.Add(taskPart, true); |
| | | WriteDBLog.Success("åå»ºæ´æ¢ç©ºçä»»å¡", $"ä»»å¡ç¼å·ï¼{taskPart.agv_tasknum}", "PCS"); |
| | | //} |
| | | } |
| | | } |
| | | } |