| | |
| | | continue; |
| | | } |
| | | string SB_Up_Location = "FJXL-TBSB" + TBSB.Replace("涂布机负极", "");//拼接涂布下料口 |
| | | //查看当前涂布机设备是否有AGV任务 |
| | | var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == SB_Up_Location); |
| | | //有结束本次循环 |
| | | if (SBtask != null) { continue; } |
| | | //当前设备有没有上料请求 |
| | | bool GYR_RFX = plc.OmronPLCClient.OmronFinsNetClient.ReadBool("D11293.00").Content; |
| | | Int16 R_Type = plc.OmronPLCClient.OmronFinsNetClient.ReadInt16("D11224").Content; |
| | | //Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), SB_Up_Location)); |
| | | if (GYR_RFX) |
| | | if (GYR_RFX && R_Type == Convert.ToInt16(1)) |
| | | { |
| | | var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == SB_Up_Location); |
| | | //有结束本次循环 |
| | | if (SBtask != null) { continue; } |
| | | #region 记录上空筒请求信号 |
| | | WriteLog.GetLog().Write($"{plc.PLCName}上空筒请求:{GYR_RFX},{R_Type}---{DateTime.Now}", $"负极涂布上空筒请求"); |
| | | #endregion |
| | | //找到路由规则(以设备为起点的路由规则) |
| | | List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_began == SB_Up_Location); |
| | | List<string> ends = Routing_Table.Select(x => x.route_end).ToList(); |
| | | if (Routing_Table.Count > 0) |
| | | { |
| | | //可用空筒缓存架 |
| | | base_ware_location location_TB = locRepository.Find(t => ends.Contains(t.upper_code) && t.location_state == LoctionStateEnum.LocationState_Stored.ToString() && t.tpgd == 1 && t.area == "FJ-TBHCJ" && t.status == 1 && t.task == 2 && t.geartype == "C").OrderBy(d => d.update_time).FirstOrDefault(); |
| | | if (location_TB != null) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | locRepository.DbContextBeginTransaction(() => |
| | | { |
| | | //生成涂布机下料任务 |
| | | dt_agvtask agvtask = new dt_agvtask() |
| | | { |
| | | agv_id = Guid.NewGuid(), |
| | | agv_tasknum = "KH-" + IdenxManager.GetTaskNo(), |
| | | agv_fromaddress = location_TB.upper_code,//以设备未起点 |
| | | agv_toaddress = SB_Up_Location, |
| | | 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_TB.update_time = DateTime.Now; |
| | | location_TB.task = 1; |
| | | var entry = locRepository.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault(); |
| | | if (entry != null) |
| | | { |
| | | entry.State = EntityState.Detached; |
| | | } |
| | | int x = locRepository.Update(location_TB, d => new { d.update_time, d.task }, true); |
| | | if (x == 1) |
| | | { |
| | | agvRepository.Add(agvtask, true); |
| | | //WriteDBLog.Info($"【{TBSB}】下料任务生成").Write($"生成任务:{agvtask.agv_tasknum},终点货位【{location_TB.upper_code}】状态:托盘光电检测:{location_TB.tpgd},状态:{location_TB.location_state},更新时间:{location_TB.wireless_time}", $"【{TBSB}】下料任务生成"); |
| | | //WriteDBLog.Info($"【{TBSB}】下料任务生成").Write($"----------------任务生成成功 {DateTime.Now} -------------- {Environment.NewLine}", $"【{TBSB}】下料任务生成"); |
| | | return content.OK(); |
| | | } |
| | | else |
| | | { |
| | | return content.Error(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | } |
| | | else if (GYR_RFX) |
| | | { |
| | | var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == SB_Up_Location); |
| | | //有结束本次循环 |
| | | if (SBtask != null) { continue; } |
| | | #region 记录下料请求信号 |
| | | WriteLog.GetLog().Write($"{plc.PLCName}下料请求:{GYR_RFX}---{DateTime.Now}", $"负极涂布下料请求"); |
| | | #endregion |
| | |
| | | foreach (var item in Routing_Table) |
| | | { |
| | | //找先找涂布区域缓存架 |
| | | location_TB = locRepository.FindFirst(t => t.upper_code == item.route_end && t.location_state == LoctionStateEnum.LocationState_Empty.ToString() && t.area == "FJ-TBHCJ" && t.status == 1 && t.task == 2); |
| | | location_TB = locRepository.FindFirst(t => t.upper_code == item.route_end && t.location_state == LoctionStateEnum.LocationState_Empty.ToString() && t.area == "FJ-TBHCJ" && t.status == 1 && t.task == 2 && t.geartype == "暂无"); |
| | | if (location_TB != null) |
| | | { |
| | | // location = location_TB.FirstOrDefault();//如果找到,赋值后退出循环 |