Commit 7181970c by chenzhengpeng

代码修改

parent dd3a1f78
......@@ -46,7 +46,7 @@ namespace Siger.ApiACC.Controllers
public AutomationController(IUnitOfWork unitOfWork, ISigerProjectLevelSectionRepository sigerProjectLevelSection, IAutomationLineMode automationLineMode, IAutomationMachineStatus automationMachineStatus, ISigerDict sigerDict, IAutomationTaskListRepository automationTaskList,
ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor, IAutomationLocationRepository automationLocation, IProductionBeatSetRepository productionBeatSet, IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,
IAutomationFixtureToolsRepository automationFixtureTools, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository automationSectionProperty,IAutomationProduceHistoryRepository automationProduceHistory)
IAutomationFixtureToolsRepository automationFixtureTools, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository automationSectionProperty, IAutomationProduceHistoryRepository automationProduceHistory)
{
_unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection;
......@@ -451,6 +451,15 @@ namespace Siger.ApiACC.Controllers
//手动模式时 退出
return;
}
//增加额外任务判断
if (!_automationTaskList.CanTask(PID, 0))
{
Logger.WriteLineInfo($"自动化业务流转--AutoProcess 已有待执行任务不能创建自动任务");
//手动模式时 退出
return;
}
/*
//自动Task任务 顺序
//1.清洗机下料
......@@ -495,9 +504,9 @@ namespace Siger.ApiACC.Controllers
}
else
{
//优先级1 :清洗机完成 。待下料
if (cleanMachine.status == (int)Automation.MachineStatus.Complated)
{
Logger.WriteLineError($"AutoProcess 有清洗机{ cleanMachine.section}完成,创建清洗机Task");
......@@ -508,7 +517,7 @@ namespace Siger.ApiACC.Controllers
if (lastTask.status == (int)TaskResultStatus.Complated)
{
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{cleanMachine.section} task:{TaskAction.Step_QXJ_LK.ToStr()} sn {lastTask.sn}");
CreateTask(invenSection.sectionid,cleanMachine.section, TaskActionType.Unload, TaskAction.Step_QXJ_LK, lastTask.fixtureguid, lastTask.fixturename, lastTask.ordercode, lastTask.sn, "无程序", lastTask.productid, lastTask.productcode, lastTask.productname, lastTask.locationid, lastTask.route);
CreateTask(invenSection.sectionid, cleanMachine.section, TaskActionType.Unload, TaskAction.Step_QXJ_LK, lastTask.fixtureguid, lastTask.fixturename, lastTask.ordercode, lastTask.sn, "无程序", lastTask.productid, lastTask.productcode, lastTask.productname, lastTask.locationid, lastTask.route);
return; //完成当前任务 退出
}
}
......@@ -523,45 +532,58 @@ namespace Siger.ApiACC.Controllers
if (location != null)
{
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{location.section} task:{TaskAction.Step_LK_JGZX.ToStr()} sn {location.sn}");
CreateTask(location.section, location.section, TaskActionType.Load, TaskAction.Step_LK_JGZX, location.fixture, location.fixturename, location.ordernumber, location.sn, location.pn, location.productId, location.productCode,location.productName, location.location, location.route);
CreateTask(location.section, location.section, TaskActionType.Load, TaskAction.Step_LK_JGZX, location.fixture, location.fixturename, location.ordernumber, location.sn, location.pn, location.productId, location.productCode, location.productName, location.location, location.route);
}
}
//优先级3:其他设备下料 (加工中心 ->清洗机)
if (cleanMachine != null)
{
var fullMachine = machineStatusList.FirstOrDefault(f => f.status == (int)Automation.MachineStatus.Complated);
if (fullMachine != null && cleanMachine.status == (int)Automation.MachineStatus.Waiting)
siger_automation_machine_status fullMachine = null;
var fullAllMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Complated);
if (fullAllMachine.Any() && cleanMachine.status == (int)Automation.MachineStatus.Waiting)
{
Logger.WriteLineError($"AutoProcess 清洗机空闲,创建普通设备下料到清洗机Task ");
//清洗机上料 为 任务触发 触发
if (tasklist != null)
if (tasklist != null && fullAllMachine.Where(p => p.section == tasklist.sectionid).Any())
{
//if (!fullAllMachine.Where(p => p.section == tasklist.sectionid).Any())
//{
// Logger.WriteLineError($"自动化业务流转-- tasklist判断,无待执行任务!");
// return;
//}
fullMachine = fullAllMachine.Where(p => p.section == tasklist.sectionid).FirstOrDefault();
Logger.WriteLineError($"AutoProcess 清洗机空闲,TaskResult触发 ");
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {tasklist.sn}");
//如果上一个任务也是清洗机上料 (清洗机未下料) 退出
var lastTask = _automationTaskList.GetList(f => f.projectId == PID, "id", true).FirstOrDefault();
if (lastTask.action== TaskAction.Step_JGZX_QXJ && lastTask.status!=(int)TaskResultStatus.Complated)
if (lastTask.action == TaskAction.Step_JGZX_QXJ && lastTask.status != (int)TaskResultStatus.Complated)
{
Logger.WriteLineError($"AutoProcess 清洗机空闲,上一个任务与本次任务指令重复");
return;
}
//创建CNC 下料到清洗机
CreateTask(cleanMachine.section, fullMachine.section, TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, tasklist.fixtureguid,tasklist.fixturename, tasklist.ordercode, tasklist.sn, tasklist.programnumber, tasklist.productid, tasklist.productcode,tasklist.productname, tasklist.locationid, tasklist.route);
CreateTask(cleanMachine.section, fullMachine.section, TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, tasklist.fixtureguid, tasklist.fixturename, tasklist.ordercode, tasklist.sn, tasklist.programnumber, tasklist.productid, tasklist.productcode, tasklist.productname, tasklist.locationid, tasklist.route);
return; //完成当前任务 退出
}
else
{
Logger.WriteLineError($"AutoProcess 清洗机空闲,MachineStatus触发 ");
var lastMonitorItem = _automationFixtureMonitor.GetList(p => p.section == fullMachine.section).OrderByDescending(p => p.id).FirstOrDefault();
if (lastMonitorItem != null)
fullMachine = fullAllMachine.First();
if (_automationTaskList.CanTask(PID, fullMachine.section))
{
var lastTask = _automationTaskList.GetList(f => f.sectionid == fullMachine.section && f.sn == lastMonitorItem.sn && f.status == (int)Automation.TaskResultStatus.Complated, "id", true).FirstOrDefault();
if (lastTask != null)
Logger.WriteLineError($"AutoProcess 清洗机空闲,MachineStatus触发 ");
var lastMonitorItem = _automationFixtureMonitor.GetList(p => p.section == fullMachine.section).OrderByDescending(p => p.id).FirstOrDefault();
if (lastMonitorItem != null)
{
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {lastTask.sn}");
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);
var lastTask = _automationTaskList.GetList(f => f.sectionid == fullMachine.section && f.sn == lastMonitorItem.sn && f.status == (int)Automation.TaskResultStatus.Complated, "id", true).FirstOrDefault();
if (lastTask != null)
{
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {lastTask.sn}");
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);
}
}
}
}
......@@ -587,7 +609,7 @@ namespace Siger.ApiACC.Controllers
/// <param name="productName"></param>
/// <param name="locationid">储位ID</param>
/// <param name="route"></param>
void CreateTask(int toSection,int fromSection, TaskActionType actionType, TaskAction taskAction, string guid,string fixtruename, string orderno, string sn, string program, int productId, string productCode,string productName, int locationid, int route)
void CreateTask(int toSection, int fromSection, TaskActionType actionType, TaskAction taskAction, string guid, string fixtruename, string orderno, string sn, string program, int productId, string productCode, string productName, int locationid, int route)
{
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Auto);
......@@ -607,9 +629,9 @@ namespace Siger.ApiACC.Controllers
operater = 0,
status = 1,
fixtureguid = guid,
fixturename=fixtruename,
fixturename = fixtruename,
productid = productId,
productname=productName,
productname = productName,
productcode = productCode,
programnumber = program,
locationid = locationid,
......@@ -617,7 +639,7 @@ namespace Siger.ApiACC.Controllers
sn = sn,
remark = EnumHelper.GetEnumDesc(taskAction),
route = route,
extend1= fromSection.ToString()
extend1 = fromSection.ToString()
});
if (_unitOfWork.Commit() > 0)
Logger.WriteLineInfo($"CreateTask sectionId:{fromSection}工站->{toSection}工站 {EnumHelper.GetEnumDesc(taskAction)} 完成");
......
......@@ -36,7 +36,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
}
else
{
var unDolist = _context.siger_automation_task_list.Where(f => f.send == 1 && f.status != (int)TaskResultStatus.Complated).Count();
var unDolist = _context.siger_automation_task_list.Where(f => f.send == 1 && f.status == (int)TaskResultStatus.Produce && f.status == (int)TaskResultStatus.Waiting).Count();
if (unDolist == 0)
return true;
else
......
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