Commit a3972ccc by jiawei.su

someupdate 新增监控SN状态 防错上下料

parent 00a1630e
...@@ -22,6 +22,7 @@ using NPOI.SS.Formula.Functions; ...@@ -22,6 +22,7 @@ using NPOI.SS.Formula.Functions;
using Siger.Middlelayer.AccRepository.Response; using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
using NPOI.SS.Formula; using NPOI.SS.Formula;
using NPOI.OpenXml4Net.OPC.Internal;
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
...@@ -551,17 +552,24 @@ namespace Siger.ApiACC.Controllers ...@@ -551,17 +552,24 @@ namespace Siger.ApiACC.Controllers
} }
else else
{ {
//优先级1 :清洗机完成 。待下料 //优先级1 :清洗机完成 。待下料
if (cleanMachine.status == (int)Automation.MachineStatus.Complated) if (cleanMachine.status == (int)Automation.MachineStatus.Complated)
{ {
Logger.WriteLineError($"AutoProcess 有清洗机{ cleanMachine.section}完成,创建清洗机Task"); Logger.WriteLineError($"AutoProcess 有清洗机{ cleanMachine.section}完成,创建清洗机Task");
var monitorClean = _automationFixtureMonitor.Get(f => f.section == cleanMachine.section);
if (monitorClean!=null)
{
if (string.IsNullOrEmpty(monitorClean.sn))
{
Logger.WriteLineError($"AutoProcess 清洗机完成,清洗监控无工件");
}else
{
//取最近完成的 Task //取最近完成的 Task
var lastTask = _automationTaskList.GetList(f => f.sectionid == cleanMachine.section, "id", true).FirstOrDefault(); var lastTask = _automationTaskList.GetList(f => f.sectionid == cleanMachine.section, "id", true).FirstOrDefault();
if (lastTask != null) if (lastTask != null)
{ {
if(lastTask.action== TaskAction.Step_QXJ_LK) if (lastTask.action == TaskAction.Step_QXJ_LK)
{ {
Logger.WriteLineError($"AutoProcess 清洗机完成,上一个任务与本次任务指令重复"); Logger.WriteLineError($"AutoProcess 清洗机完成,上一个任务与本次任务指令重复");
return; //任务重复 return; //任务重复
...@@ -578,6 +586,9 @@ namespace Siger.ApiACC.Controllers ...@@ -578,6 +586,9 @@ namespace Siger.ApiACC.Controllers
} }
} }
} }
}
}
//优先级2 :其他设备待上料 (立库->加工中心) //优先级2 :其他设备待上料 (立库->加工中心)
var freeMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Waiting); var freeMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Waiting);
if (freeMachine != null) if (freeMachine != null)
...@@ -602,7 +613,7 @@ namespace Siger.ApiACC.Controllers ...@@ -602,7 +613,7 @@ namespace Siger.ApiACC.Controllers
//优先级3:其他设备下料 (加工中心 ->清洗机) //优先级3:其他设备下料 (加工中心 ->清洗机)
if (cleanMachine != null) if (cleanMachine != null)
{ {
siger_automation_machine_status fullMachine = null; //siger_automation_machine_status fullMachine = null;
var fullAllMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Complated); var fullAllMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Complated);
if (fullAllMachine.Any() && cleanMachine.status == (int)Automation.MachineStatus.Waiting) if (fullAllMachine.Any() && cleanMachine.status == (int)Automation.MachineStatus.Waiting)
...@@ -611,7 +622,7 @@ namespace Siger.ApiACC.Controllers ...@@ -611,7 +622,7 @@ namespace Siger.ApiACC.Controllers
//清洗机上料 为 任务触发 触发 //清洗机上料 为 任务触发 触发
if (tasklist != null && fullAllMachine.Where(p => p.section == tasklist.sectionid).Any()) if (tasklist != null && fullAllMachine.Where(p => p.section == tasklist.sectionid).Any())
{ {
fullMachine = fullAllMachine.Where(p => p.section == tasklist.sectionid).FirstOrDefault(); var fullMachine = fullAllMachine.Where(p => p.section == tasklist.sectionid).FirstOrDefault();
Logger.WriteLineError($"AutoProcess 清洗机空闲,TaskResult触发 "); Logger.WriteLineError($"AutoProcess 清洗机空闲,TaskResult触发 ");
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {tasklist.sn}"); Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {tasklist.sn}");
...@@ -631,24 +642,26 @@ namespace Siger.ApiACC.Controllers ...@@ -631,24 +642,26 @@ namespace Siger.ApiACC.Controllers
} }
else else
{ {
var fullmids = fullAllMachine.Select(s => s.section).ToList();
fullMachine = fullAllMachine.First(); var lastMonitorItem = _automationFixtureMonitor.GetList(p => fullmids.Contains(p.section) && !string.IsNullOrEmpty(p.sn)).OrderByDescending(p => p.id).FirstOrDefault();
if (_automationTaskList.CanTask(PID, fullMachine.section)) if (lastMonitorItem==null)
{ {
Logger.WriteLineError($"AutoProcess 清洗机空闲,MachineStatus触发 "); Logger.WriteLineError($"AutoProcess 清洗机空闲,设备监控无可下料的设备 ");
var lastMonitorItem = _automationFixtureMonitor.GetList(p => p.section == fullMachine.section).OrderByDescending(p => p.id).FirstOrDefault(); return;
if (lastMonitorItem != null) }
if (_automationTaskList.CanTask(PID, lastMonitorItem.section))
{ {
var lastTask = _automationTaskList.GetList(f => f.sectionid == fullMachine.section && f.sn == lastMonitorItem.sn && f.status == (int)Automation.TaskResultStatus.Complated, "id", true).FirstOrDefault(); Logger.WriteLineError($"AutoProcess 清洗机空闲,MachineStatus触发 ");
var lastTask = _automationTaskList.GetList(f => f.sectionid == lastMonitorItem.section && f.sn == lastMonitorItem.sn && f.status == (int)Automation.TaskResultStatus.Complated, "id", true).FirstOrDefault();
if (lastTask != null) if (lastTask != null)
{ {
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {lastTask.sn}"); Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{lastMonitorItem.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {lastTask.sn}");
if (TargetFree(cleanMachine.section, fullMachine.section, TaskAction.Step_JGZX_QXJ)) if (TargetFree(cleanMachine.section, lastMonitorItem.section, TaskAction.Step_JGZX_QXJ))
{ {
CreateTask(cleanMachine.section, fullMachine.section, TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, lastTask.fixtureguid, lastTask.fixturename, lastTask.ordercode, lastTask.sn, lastTask.programnumber, lastTask.productid, lastTask.productcode, lastTask.productname, lastTask.locationid, lastTask.route); CreateTask(cleanMachine.section, lastMonitorItem.section, TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, lastTask.fixtureguid, lastTask.fixturename, lastTask.ordercode, lastTask.sn, lastTask.programnumber, lastTask.productid, lastTask.productcode, lastTask.productname, lastTask.locationid, lastTask.route);
}
} }
} }
} }
} }
} }
...@@ -716,9 +729,21 @@ namespace Siger.ApiACC.Controllers ...@@ -716,9 +729,21 @@ namespace Siger.ApiACC.Controllers
{ {
// 当前空闲设备能加工的产品 // 当前空闲设备能加工的产品
var beats = _productionBeatSet.GetList(f => f.projectID == PID && machines.Contains(f.machineID) && f.status == (int)RowState.Valid).ToList(); var beats = _productionBeatSet.GetList(f => f.projectID == PID && machines.Contains(f.machineID) && f.status == (int)RowState.Valid).ToList();
var TempList = new List<ResponseAutoRouteInfo>(); var TempList = new List<ResponseAutoRouteInfo>();
foreach (var b in beats) foreach (var b in beats)
{ {
var moniter = _automationFixtureMonitor.Get(f => f.section ==b.section_id);
if (moniter != null)
{
//防错 监控设备中无SN 加工的工站
if (!string.IsNullOrEmpty(moniter.sn))
{
Logger.WriteLineInfo($"CreateTask machineId:{b.machineID} 设备上有SN在加工");
continue;
}
}
Logger.WriteLineError($"SelectLocation 设备{b.machineID}标准节拍{b.route_number}{b.route_name}"); Logger.WriteLineError($"SelectLocation 设备{b.machineID}标准节拍{b.route_number}{b.route_name}");
var autoLocationIds = _automationLocation.GetList(f => f.status == (int)RowState.Valid && f.projectId == b.projectID && f.routeid == b.route_number.ToInt() && f.productid == b.product_name.ToInt()); var autoLocationIds = _automationLocation.GetList(f => f.status == (int)RowState.Valid && f.projectId == b.projectID && f.routeid == b.route_number.ToInt() && f.productid == b.product_name.ToInt());
if (!autoLocationIds.Any()) if (!autoLocationIds.Any())
......
...@@ -130,6 +130,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -130,6 +130,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join pd in _context.siger_project_product on p.product_id equals pd.id join pd in _context.siger_project_product on p.product_id equals pd.id
where q.projectId == projectId && d.OrderNumber == ordernumber where q.projectId == projectId && d.OrderNumber == ordernumber
&& q.status == (int)RowState.Valid && t.status == (int)RowState.Valid && l.status==(int)RowState.Valid && q.status == (int)RowState.Valid && t.status == (int)RowState.Valid && l.status==(int)RowState.Valid
&& string.IsNullOrEmpty(l.sn)
select new ResponsePlanlFixtureInfo select new ResponsePlanlFixtureInfo
{ {
OrderNumber = ordernumber, OrderNumber = ordernumber,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment