| | |
| | | //当前设备有没有上料请求 |
| | | OperateResult<bool> GYR_RFX = plc.MelsecPLCClient.MelsecMcNetClient.ReadBool("D5493.0"); |
| | | Int16 tf = Convert.ToInt16(GYR_RFX.Content); |
| | | if (GYR_RFX.Content) |
| | | OperateResult<Int16> R_Type = plc.MelsecPLCClient.MelsecMcNetClient.ReadInt16("D5424"); |
| | | if (GYR_RFX.Content && R_Type.Content==Convert.ToInt16(2)) |
| | | { |
| | | //查看当前辊分机设备是否有AGV任务 |
| | | var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == plc.EquipType); |
| | | //有结束本次循环 |
| | | if (SBtask != null) { continue; } |
| | | #region 记录下空筒请求信号 |
| | | WriteLog.GetLog().Write($"{plc.PLCName}下空筒请求:{GYR_RFX.Content},{R_Type.Content}---{DateTime.Now}", $"负极棍分下空筒请求"); |
| | | #endregion |
| | | List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_end == plc.EquipType); |
| | | List<string> begans = Routing_Table.Select(x=>x.route_began).ToList(); |
| | | base_ware_location ware_Location = locRepository.Find(d => begans.Contains(d.upper_code) && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.area == "FJ-TBHCJ" && d.status == 1 && d.task == 2 && d.geartype == "C").OrderBy(d => d.update_time).FirstOrDefault(); |
| | | |
| | | if (ware_Location != null) |
| | | { |
| | | base_ware_location Location = ware_Location; |
| | | //生成涂布机下料任务 |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = "KH-" + IdenxManager.GetTaskNo(), |
| | | agv_fromaddress = plc.EquipType,//以设备为起点 |
| | | agv_toaddress = Location.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 = "", |
| | | }; |
| | | |
| | | //Location.update_time = DateTime.Now; |
| | | Location.update_time = DateTime.Now; |
| | | Location.task = 1; |
| | | var entry = locRepository.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault(); |
| | | if (entry != null) |
| | | { |
| | | entry.State = EntityState.Detached; |
| | | } |
| | | int a = locRepository.Update(Location, d => new { d.task, d.update_time }, true); |
| | | if (a == 1) |
| | | { |
| | | agvRepository.Add(agvtask, true); |
| | | } |
| | | } |
| | | } |
| | | else if(GYR_RFX.Content) |
| | | { |
| | | //查看当前辊分机设备是否有AGV任务 |
| | | var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == plc.EquipType); |
| | |
| | | List<base_ware_location> loctionList = new List<base_ware_location>(); |
| | | foreach (var item in Routing_Table) |
| | | { |
| | | base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == item.route_began && d.status == 1 && d.location_state == LoctionStateEnum.LocationState_Stored.ToString() && d.logic_col == 1 && d.task == 2); |
| | | base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == item.route_began && d.status == 1 && d.location_state == LoctionStateEnum.LocationState_Stored.ToString() && d.logic_col == 1 && d.task == 2 && d.geartype == "暂无"); |
| | | if (ware_Locations == null) |
| | | { |
| | | continue; |