| | |
| | | using WIDESEA_Common.LoctionEnum; |
| | | using WIDESEA_Common.Tools; |
| | | using WIDESEA_Core.EFDbContext; |
| | | using WIDESEA_Core.Extensions; |
| | | using WIDESEA_Core.Utilities; |
| | | using WIDESEA_Entity.DomainModels; |
| | | using WIDESEA_Services.IRepositories; |
| | |
| | | using static FreeSql.Internal.GlobalFilter; |
| | | |
| | | namespace WIDESEA_WCS.SchedulerExecute.AGV |
| | | { |
| | | { |
| | | public partial class AGVSchedulerExecute |
| | | { |
| | | /// <summary> |
| | | /// 辊分下料缓存架良品料自动搬运极库 |
| | | /// </summary> |
| | | public static async void AgvAndEquiWorkZJ() |
| | | { |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | VOLContext Context = new VOLContext(); |
| | | Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context); |
| | | Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context); |
| | | Ibase_ware_locationRepository ibase_Ware_Location = new base_ware_locationRepository(Context); |
| | | |
| | | List<base_ware_location> ware_Locatiolist = ibase_Ware_Location.Find(d => d.upper_code.Contains("GFHCJ")&&d.logic_col==1&&d.task==2 && d.status == 1&& d.geartype != "暂无").ToList(); |
| | | List<base_ware_location> ware_Locatiolist = ibase_Ware_Location.Find(d => d.upper_code.Contains("GFHCJ") && d.logic_col == 1 && d.task == 2 && d.status == 1 && d.geartype != "暂无").ToList(); |
| | | |
| | | //if (ware_Locatio == null) |
| | | //{ |
| | |
| | | //} |
| | | foreach (var listloction in ware_Locatiolist) |
| | | { |
| | | List<base_ware_location> gfloction = new List<base_ware_location>(); |
| | | List<base_routing_table> routing_table = routingRepository.Find(v => v.route_began == listloction.upper_code).ToList(); |
| | | if (routing_table.Count > 0) |
| | | { |
| | | foreach (var item in routing_table) |
| | | List<base_ware_location> gfloction = new List<base_ware_location>(); |
| | | List<base_routing_table> routing_table = routingRepository.Find(v => v.route_began == listloction.upper_code).ToList(); |
| | | if (routing_table.Count > 0) |
| | | { |
| | | base_ware_location ware_Location = ibase_Ware_Location.FindFirst(d => d.upper_code == item.route_end && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.logic_col == 0 && d.tpgd == 0 && d.status == 1 && d.task == 2 && d.geartype== "暂无"); |
| | | if (ware_Location != null) |
| | | foreach (var item in routing_table) |
| | | { |
| | | gfloction.Add(ware_Location); |
| | | base_ware_location ware_Location = ibase_Ware_Location.FindFirst(d => d.upper_code == item.route_end && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.logic_col == 0 && d.tpgd == 0 && d.status == 1 && d.task == 2 && d.geartype == "暂无"); |
| | | if (ware_Location != null) |
| | | { |
| | | gfloction.Add(ware_Location); |
| | | } |
| | | } |
| | | } |
| | | if (gfloction.Count > 0) |
| | | { |
| | | base_ware_location ware_Locatio = ibase_Ware_Location.FindFirst(d => d.upper_code == listloction.upper_code); |
| | | if (gfloction.Count > 0) |
| | | { |
| | | base_ware_location ware_Locatio = ibase_Ware_Location.FindFirst(d => d.upper_code == listloction.upper_code); |
| | | if (ware_Locatio == null) { continue; } |
| | | base_ware_location lotion = gfloction.OrderBy(d => d.order_num).FirstOrDefault(); |
| | | dt_agvtask agvtask = new dt_agvtask |
| | | { |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = "KH-" + IdenxManager.GetTaskNo(), |
| | | agv_fromaddress = ware_Locatio.upper_code, |
| | | agv_toaddress = lotion.upper_code, |
| | | agv_code = "组装AGV调度", |
| | | agv_remark = "辊分下料呼叫", |
| | | agv_taskstate = AGVTaskStateEnum.Create.ToString(), |
| | | agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(), |
| | | agv_worktype = 1,//工作类型 |
| | | agv_materielid = "", |
| | | agv_qty = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_grade = 0,//任务优先级 |
| | | agv_userid = "WCS", |
| | | agv_barcode = "" |
| | | }; |
| | | listloction.update_time = DateTime.Now; |
| | | ware_Locatio.logic_col = 1;//设置良品物料 |
| | | ware_Locatio.task = 1;//设置任务生成1 |
| | | ware_Locatio.light_color = "无"; |
| | | var entrys = ibase_Ware_Location.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault(); |
| | | if (entrys != null) |
| | | { |
| | | entrys.State = EntityState.Detached; |
| | | } |
| | | int begin= ibase_Ware_Location.Update(ware_Locatio, d => new { d.logic_col, d.task, d.update_time, d.light_color }, true); |
| | | base_ware_location lotion = gfloction.OrderBy(d => d.order_num).FirstOrDefault(); |
| | | dt_agvtask agvtask = new dt_agvtask |
| | | { |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = "KH-" + IdenxManager.GetTaskNo(), |
| | | agv_fromaddress = ware_Locatio.upper_code, |
| | | agv_toaddress = lotion.upper_code, |
| | | agv_code = "组装AGV调度", |
| | | agv_remark = "辊分下料呼叫", |
| | | agv_taskstate = AGVTaskStateEnum.Create.ToString(), |
| | | agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(), |
| | | agv_worktype = 1,//工作类型 |
| | | agv_materielid = "", |
| | | agv_qty = 1, |
| | | agv_createtime = DateTime.Now, |
| | | agv_grade = 0,//任务优先级 |
| | | agv_userid = "WCS", |
| | | agv_barcode = "" |
| | | }; |
| | | listloction.update_time = DateTime.Now; |
| | | ware_Locatio.logic_col = 1;//设置良品物料 |
| | | ware_Locatio.task = 1;//设置任务生成1 |
| | | ware_Locatio.light_color = "无"; |
| | | var entrys = ibase_Ware_Location.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault(); |
| | | if (entrys != null) |
| | | { |
| | | entrys.State = EntityState.Detached; |
| | | } |
| | | int begin = ibase_Ware_Location.Update(ware_Locatio, d => new { d.logic_col, d.task, d.update_time, d.light_color }, true); |
| | | |
| | | lotion.update_time = DateTime.Now; |
| | | lotion.logic_col = 1; |
| | | lotion.task = 1; |
| | | lotion.geartype = ware_Locatio.geartype; |
| | | var entry = ibase_Ware_Location.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault(); |
| | | if (entry != null) |
| | | { |
| | | entry.State = EntityState.Detached; |
| | | } |
| | | int end= ibase_Ware_Location.Update(lotion, d => new { d.logic_col, d.task, d.update_time, d.geartype }, true); |
| | | if (begin==1&&end==1) |
| | | { |
| | | agvRepository.Add(agvtask, true);//任务生成 |
| | | WriteDBLog.Info($"辊分到极库任务生成").Write($"生成任务:{agvtask.agv_tasknum}", $"辊分到极库任务生成"); |
| | | WriteDBLog.Info($"辊分到极库任务生成").Write($"起点货位【{ware_Locatio.upper_code}】状态:托盘光电检测:{ware_Locatio.tpgd},-1光电:{ware_Locatio.gd2},-2光电:{ware_Locatio.gd1},-3光电:{ware_Locatio.gd4},-4光电:{ware_Locatio.gd3},状态:{ware_Locatio.location_state},更新时间:{ware_Locatio.wireless_time}", $"辊分到极库任务生成"); |
| | | WriteDBLog.Info($"辊分到极库任务生成").Write($"终点货位【{lotion.upper_code}】状态:托盘光电检测:{lotion.tpgd},状态:{lotion.location_state},更新时间:{lotion.wireless_time}", $"辊分到极库任务生成"); |
| | | WriteDBLog.Info($"辊分到极库任务生成").Write($"----------------任务生成成功 {DateTime.Now} -------------- {Environment.NewLine}", $"辊分到极库任务生成"); |
| | | return; |
| | | lotion.update_time = DateTime.Now; |
| | | lotion.logic_col = 1; |
| | | lotion.task = 1; |
| | | lotion.geartype = ware_Locatio.geartype; |
| | | var entry = ibase_Ware_Location.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault(); |
| | | if (entry != null) |
| | | { |
| | | entry.State = EntityState.Detached; |
| | | } |
| | | int end = ibase_Ware_Location.Update(lotion, d => new { d.logic_col, d.task, d.update_time, d.geartype }, true); |
| | | if (begin == 1 && end == 1) |
| | | { |
| | | agvRepository.Add(agvtask, true);//任务生成 |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |