Commit 7b1993d6 by jiawei.su

someupdate

parent aa1df8d2
...@@ -246,7 +246,6 @@ namespace Siger.ApiACC.Controllers ...@@ -246,7 +246,6 @@ namespace Siger.ApiACC.Controllers
taskObj.operatetime = DateTime.Now; taskObj.operatetime = DateTime.Now;
taskObj.completetime = DateTime.Now; taskObj.completetime = DateTime.Now;
var monitor = _automationFixtureMonitor.Get(f => f.section == taskObj.sectionid); var monitor = _automationFixtureMonitor.Get(f => f.section == taskObj.sectionid);
var sectionProperty = _automationSectionProperty.Get(f => f.sectionid == taskObj.extend1.ToInt()); var sectionProperty = _automationSectionProperty.Get(f => f.sectionid == taskObj.extend1.ToInt());
if (sectionProperty == null) if (sectionProperty == null)
...@@ -264,145 +263,112 @@ namespace Siger.ApiACC.Controllers ...@@ -264,145 +263,112 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(AccEnum.MachineDisable); throw new BadRequestException(AccEnum.MachineDisable);
} }
// 业务入口: 上料位-》 入库 如果是上料工装 安装完成 ,绑定 储位与装配 // 业务入口: 上料位-》 入库 如果是上料工装 安装完成 ,绑定 储位与装配
if (sectionProperty.propertytype == 1)
var download = false;
if (sectionProperty.down > 2)
{
// 是拆卸
download = true;
}
//绑定SN 工件到立库储位
if (taskObj.action == TaskAction.Step_SXLW_LK)
{ {
location.fixturetools = taskObj.fixtureguid; var download = false;
location.fixturename = taskObj.fixturename; if (sectionProperty.down > 2)
location.ordernumber = taskObj.ordercode; {
location.productcode = download ? "" : taskObj.productcode; // 是拆卸
location.productid = download ? 0 : taskObj.productid; download = true;
location.routeid = download ? 0 : taskObj.route; }
location.route = download ? "" : taskObj.route.ToString(); //绑定SN 工件到立库储位
location.sn = download ? "" : taskObj.sn; if (taskObj.action == TaskAction.Step_SXLW_LK)
location.status = (int)LocationStatus.In; {
_automationLocation.Update(location); location.fixturetools = taskObj.fixtureguid;
location.fixturename = taskObj.fixturename;
sectionProperty.upload = 0; location.ordernumber = taskObj.ordercode;
sectionProperty.down = 0; location.productcode = download ? "" : taskObj.productcode;
_automationSectionProperty.Update(sectionProperty); location.productid = download ? 0 : taskObj.productid;
location.routeid = download ? 0 : taskObj.route;
location.route = download ? "" : taskObj.route.ToString();
location.sn = download ? "" : taskObj.sn;
location.status = (int)LocationStatus.In;
_automationLocation.Update(location);
sectionProperty.upload = 0;
sectionProperty.down = 0;
_automationSectionProperty.Update(sectionProperty);
}
//从立库储位拿SN 工件到上料位
if (taskObj.action == TaskAction.Step_LK_SXLW)
{
location.sn = taskObj.sn;
location.productcode = taskObj.productcode;
location.productid = taskObj.productid;
location.productname = taskObj.productname;
location.route = taskObj.route.ToString();
location.routeid = taskObj.route;
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
} }
//从立库储位拿SN 工件到上料位
if (taskObj.action == TaskAction.Step_LK_SXLW)
{
location.sn = taskObj.sn;
location.ordernumber = taskObj.ordercode;
location.productcode = taskObj.productcode;
location.productid = taskObj.productid;
location.productname = taskObj.productname;
location.route = taskObj.route.ToString();
location.routeid = taskObj.route;
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
}
if (taskObj.action == TaskAction.Step_LK_CJT) //上料中
{ if (sectionProperty.upload != 0)
{
sectionProperty.upload += 1;
_automationSectionProperty.Update(sectionProperty);
}
if (sectionProperty.down != 0)
{
sectionProperty.down += 1;
_automationSectionProperty.Update(sectionProperty);
}
} }
//上料中
if (sectionProperty.upload != 0)
{
sectionProperty.upload += 1;
_automationSectionProperty.Update(sectionProperty);
}
if (sectionProperty.down != 0)
{
sectionProperty.down += 1;
_automationSectionProperty.Update(sectionProperty);
}
// CNC 设备 // CNC 设备
if (sectionProperty.propertytype == 2)
if (taskObj.action == TaskAction.Step_LK_JGZX)
{ {
var route = _productRoute.GetList(f => f.productId == taskObj.productid && f.id != taskObj.route && f.status == (int)RowState.Valid, "serialNumber", false).FirstOrDefault(); if (taskObj.action == TaskAction.Step_LK_JGZX)
if (route == null)
{
throw new BadRequestException(AccEnum.ProductRouteMissing);
}
location.routeid = route.id;
location.route = route.id.ToString();
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
//加工中心做完 下一站清洗机
var cleanMachine = _automationSectionProperty.Get(f => f.propertytype == 4);
if (cleanMachine != null)
{ {
taskObj.extend1 = cleanMachine.sectionid.ToString(); location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
} }
} }
//抽检台 //抽检台
if (sectionProperty.propertytype == 3)
if (taskObj.action == TaskAction.Step_LK_CJT)
{
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
}
if (taskObj.action == TaskAction.Step_CJT_SXLW)
{ {
if (taskObj.action == TaskAction.Step_LK_CJT)
{
location.status = (int)LocationStatus.Out;
_automationLocation.Update(location);
}
if (taskObj.action == TaskAction.Step_CJT_SXLW)
{
} }
}
//清洗机 //清洗机
if (sectionProperty.propertytype == 4)
if (taskObj.action == TaskAction.Step_QXJ_LK)
{ {
if (taskObj.action == TaskAction.Step_QXJ_LK)
var currenRute = _productRoute.Get(f => f.id == taskObj.route);
if (currenRute == null)
{ {
throw new BadRequestException(AccEnum.ProductRouteMissing);
}
var nextRoute = _productRoute.GetList(f => f.productId == taskObj.productid && f.serialNumber > currenRute.serialNumber && f.status == (int)RowState.Valid, "serialNumber", false).FirstOrDefault();
var route = 0; var currenRute = _productRoute.Get(f => f.id == taskObj.route);
if (nextRoute != null) if (currenRute == null)
{ {
route = nextRoute.id; throw new BadRequestException(AccEnum.ProductRouteMissing);
}
var nextRoute = _productRoute.GetList(f => f.productId == taskObj.productid && f.serialNumber > currenRute.serialNumber && f.status == (int)RowState.Valid, "serialNumber", false).FirstOrDefault();
var route = 0;
if (nextRoute != null)
{
route = nextRoute.id;
}
//更新下一到工序
location.routeid = route;
location.route = route.ToString();
location.status = (int)LocationStatus.In;
_automationLocation.Update(location);
Logger.WriteLineInfo($"PlCfeeback 工装储位{taskObj.locationid} 工序{location.routeid} 下一工序{route}更新完成");
} }
//更新下一到工序
location.routeid = route;
location.route = route.ToString();
location.status = (int)LocationStatus.In;
_automationLocation.Update(location);
Logger.WriteLineInfo($"PlCfeeback 工装储位{taskObj.locationid} 工序{location.routeid}-{location.routenum}完成");
Logger.WriteLineInfo($"PlCfeeback 工装储位{taskObj.locationid} 下一工序{route}更新完成");
//if (route.id == location.routeid)
//{
// Logger.WriteLineInfo($"PlCfeeback 工装储位{taskObj.locationid} 工序{location.routeid}-{location.routenum}完成");
// //最后一道工序
// location.routeid = 0;
// location.route = "0";
// location.status = (int)LocationStatus.In;
// _automationLocation.Update(location);
//}
//else
//{
// Logger.WriteLineInfo($"PlCfeeback 工装储位{taskObj.locationid} 工序{location.routeid}-{location.routenum}为完成");
//}
} }
if (monitor == null) if (monitor == null)
{ {
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor _automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
...@@ -531,6 +497,7 @@ namespace Siger.ApiACC.Controllers ...@@ -531,6 +497,7 @@ namespace Siger.ApiACC.Controllers
{ {
//优先级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");
...@@ -540,8 +507,6 @@ namespace Siger.ApiACC.Controllers ...@@ -540,8 +507,6 @@ namespace Siger.ApiACC.Controllers
{ {
if (lastTask.status == (int)TaskResultStatus.Complated) if (lastTask.status == (int)TaskResultStatus.Complated)
{ {
lastTask.extend1 = string.Empty;
_automationTaskList.Update(lastTask);
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{cleanMachine.section} task:{TaskAction.Step_QXJ_LK.ToStr()} sn {lastTask.sn}"); 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; //完成当前任务 退出 return; //完成当前任务 退出
...@@ -673,20 +638,17 @@ namespace Siger.ApiACC.Controllers ...@@ -673,20 +638,17 @@ namespace Siger.ApiACC.Controllers
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())
{ {
Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 没有匹配到当前储位");
continue; continue;
} }
foreach (var autoLocation in autoLocationIds) foreach (var autoLocation in autoLocationIds)
{ {
if (string.IsNullOrEmpty(autoLocation.sn)) if (string.IsNullOrEmpty(autoLocation.sn))
{ {
Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 储位{autoLocation.locationid}没有SN工件");
continue; continue;
} }
if (autoLocation.status == 2) if (autoLocation.status == 2)
{ {
//SN不在立库内 //SN不在立库内
Logger.WriteLineError($"SelectLocation 设备{b.machineID} routeid:{b.route_number}-{b.route_name}productId:{b.product_name} 储位{autoLocation.locationid}工件Sn:{autoLocation.sn}不在储位上");
continue; continue;
} }
if (autoLocation.routeid == 0) if (autoLocation.routeid == 0)
...@@ -712,8 +674,6 @@ namespace Siger.ApiACC.Controllers ...@@ -712,8 +674,6 @@ namespace Siger.ApiACC.Controllers
Sn = autoLocation.sn, Sn = autoLocation.sn,
LId = autoLocation.id LId = autoLocation.id
}); });
Logger.WriteLineError($"SelectLocation 有效订单号{autoLocation.ordernumber}");
} }
} }
if (!TempList.Any()) if (!TempList.Any())
......
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