Commit 3817cbfb by xin.yang
parents 516f46c9 22cc76a4
......@@ -19,6 +19,7 @@ using Siger.Middlelayer.Share.Enum.ModuleEnum;
using static Siger.Middlelayer.Share.Enum.ModuleEnum.Automation;
using Siger.Middlelayer.Repository.Entities;
using NPOI.SS.Formula.Functions;
using Siger.Middlelayer.AccRepository.Response;
namespace Siger.ApiACC.Controllers
{
......@@ -82,6 +83,7 @@ namespace Siger.ApiACC.Controllers
exitsObj.enable = request.enable;
exitsObj.status = request.status;
exitsObj.updatetime = DateTime.Now;
_automationMachineStatus.Update(exitsObj);
}
......@@ -316,6 +318,7 @@ namespace Siger.ApiACC.Controllers
location.productcode = taskObj.productcode;
location.productid = taskObj.productid;
location.sn = taskObj.sn;
_automationLocation.Update(location);
}
}
else if (taskObj.action == TaskAction.Step_LK_CJT || taskObj.action == TaskAction.Step_LK_JGZX || taskObj.action == TaskAction.Step_LK_SXLW)
......@@ -395,7 +398,7 @@ namespace Siger.ApiACC.Controllers
var updownDic= stationDicts.Where(s => s.dkey == DictKeyValConst.UploadloadStation);
var uploadStations = updownDic.Select(f => f.dval).ToList();
var uploadStations = updownDic.Select(f => f.dval.ToInt()).ToList();
/* 自动任务创建只有CNC 设备;排除上料设备(手动任务) */
......@@ -407,8 +410,8 @@ namespace Siger.ApiACC.Controllers
return;
}
// 获取可用 设备状态列表
var machineStatusList = _automationMachineStatus.GetList(f => f.projectId == PID && f.enable == 1);
// 获取可用 设备状态列表 排除上料工位
var machineStatusList = _automationMachineStatus.GetList(f => f.projectId == PID && !uploadStations.Contains(f.section) && f.enable == 1);
if (!machineStatusList.Any())
{
Logger.WriteLineInfo($"AutoProcess 无可用状态的设备");
......@@ -421,19 +424,15 @@ namespace Siger.ApiACC.Controllers
if (cleanMachine.status == (int)Automation.MachineStatus.Complated)
{
Logger.WriteLineInfo($"AutoProcess 有清洗机完成,创建清洗机Task");
var uploadPostion = uploadStations.Exists(f => f.Contains(cleanMachine.section.ToString()));
if (uploadPostion)
{
Logger.WriteLineInfo($"AutoProcess 上料料工站 无需自动创建任务 ");
return;
}
var monitor = _automationFixtureMonitor.Get(f => f.section == cleanMachine.section);
if (monitor==null)
{
Logger.WriteLineInfo($"AutoProcess 找不到CNC监控信息");
return;
}
CreateTask(cleanMachine,TaskActionType.Unload, TaskAction.Step_QXJ_LK,monitor.fixtureguid,monitor.ordernumber,monitor.sn,monitor.productCode,monitor.locationId);
CreateTask(cleanMachine,TaskActionType.Unload, TaskAction.Step_QXJ_LK,monitor.fixtureguid,monitor.ordernumber,monitor.sn,"无程序",monitor.productCode,monitor.locationId);
return; //完成当前任务 退出
}
}
......@@ -444,19 +443,15 @@ namespace Siger.ApiACC.Controllers
if (freeMachine != null)
{
Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备上料Task");
var uploadPostion = uploadStations.Exists(f => f.Contains(freeMachine.section.ToString()));
if (uploadPostion)
{
Logger.WriteLineInfo($"AutoProcess 上料料工站 无需自动创建任务 ");
return;
}
var location = SelectLocation(freeMachine.machineid);
if (location==null)
{
Logger.WriteLineInfo($"AutoProcess 找不到储位信息");
return;
}
CreateTask(freeMachine,TaskActionType.Load ,TaskAction.Step_LK_JGZX,location.guid,location.ordernumber,location.sn,location.productcode,location.locationid);
CreateTask(freeMachine,TaskActionType.Load ,TaskAction.Step_LK_JGZX,location.fixture,location.ordernumber,location.sn,location.pn,location.productCode,location.location);
return; //完成当前任务 退出
}
//优先级3:其他设备下料 (加工中心 ->立库)
......@@ -466,19 +461,15 @@ namespace Siger.ApiACC.Controllers
if (fullMachine != null && cleanMachine.status==(int)Automation.MachineStatus.Waiting)
{
Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备下料Task ");
var uploadPostion = uploadStations.Exists(f => f.Contains(cleanMachine.section.ToString()));
if (uploadPostion)
{
Logger.WriteLineInfo($"AutoProcess 上料料工站 无需自动创建任务 ");
return;
}
var monitor = _automationFixtureMonitor.Get(f => f.section == cleanMachine.section);
if (monitor == null)
{
Logger.WriteLineInfo($"AutoProcess 找不到CNC监控信息");
return;
}
CreateTask(fullMachine,TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, monitor.fixtureguid, monitor.ordernumber, monitor.sn, monitor.productCode, monitor.locationId);
CreateTask(fullMachine,TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, monitor.fixtureguid, monitor.ordernumber, monitor.sn,"无程序", monitor.productCode, monitor.locationId);
return; //完成当前任务 退出
}
......@@ -498,7 +489,7 @@ namespace Siger.ApiACC.Controllers
/// <param name="sn">工件</param>
/// <param name="productCode">产品CODE</param>
/// <param name="locationid">储位ID</param>
void CreateTask(siger_automation_machine_status machineStatus,TaskActionType actionType, TaskAction taskAction,string guid,string orderno,string sn,string productCode,int locationid)
void CreateTask(siger_automation_machine_status machineStatus,TaskActionType actionType, TaskAction taskAction,string guid,string orderno,string sn,string program,string productCode,int locationid)
{
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Auto);
_automationTaskList.Insert(new siger_automation_task_list
......@@ -518,6 +509,7 @@ namespace Siger.ApiACC.Controllers
status = 1,
fixtureguid= guid,
productcode= productCode,
programnumber=program,
locationid= locationid,
ordercode= orderno,
sn= sn,
......@@ -534,7 +526,7 @@ namespace Siger.ApiACC.Controllers
/// <summary>
/// 自动匹配储位 储位 ->CNC
/// </summary>
siger_automation_location SelectLocation(int machine)
ResponseAutomationLocationRouteInfo SelectLocation(int machine)
{
// 当前空闲设备能加工的产品
var beats = _productionBeatSet.GetList(f => f.projectID == PID && f.machineID == machine);
......@@ -550,8 +542,8 @@ namespace Siger.ApiACC.Controllers
var order = planOrder.FirstOrDefault();
//TODO 20210126
//var beatset = beats.Where(f => f.product_name == order.productId.ToString());
//var location = _automationLocation.GetList(f => f.projectId == PID && f.ordernumber== order.ordernumber && productIds.Contains(f.productid));
var beatset = beats.Where(f => f.product_name == order.productId.ToString());
//var location = _automationLocation.GetList(f => f.projectId == PID && f.ordernumber == order.ordernumber && productIds.Contains(f.productid));
//if (!location.Any())
//{
// Logger.WriteLineInfo($"SelectLocation 未找到最近交期订单号{order.ordernumber} 对应产品 {order.productName}的储位信息");
......@@ -560,12 +552,30 @@ namespace Siger.ApiACC.Controllers
//}
//储位有SN 工件
var location = _automationLocation.GetList(f => f.projectId == PID && productIds.Contains(f.productid));
var location = _automationLocation.GetList(f => f.projectId == PID && productIds.Contains(f.productid));
var hasSnloaction = location.Where(f =>!string.IsNullOrEmpty(f.sn));
if (!hasSnloaction.Any())
return null;
return null;
var result = location.FirstOrDefault();
return location.FirstOrDefault();
var valiateBeat = beatset.FirstOrDefault(f=>f.route_number.ToInt()>result.routenum);
if (valiateBeat==null)
{
Logger.WriteLineInfo($"SelectLocation 未找到产品的工艺顺序");
return null;
}
return new ResponseAutomationLocationRouteInfo
{
fixture = result.fixturetools,
ordernumber=result.ordernumber,
location=result.locationid,
productCode=result.productcode,
sn=result.sn,
pn= valiateBeat.process_number,
route=valiateBeat.route_name
};
}
......
......@@ -38,6 +38,11 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 每加工CNC 设备 经过的工序: 标准节拍表
/// </summary>
public string route { get; set; }
/// <summary>
/// 工序顺序
/// </summary>
public int routenum { get; set; }
/// <summary>
/// 附件
/// </summary>
......
......@@ -28,4 +28,16 @@ namespace Siger.Middlelayer.AccRepository.Response
/// </summary>
public string fixture { get; set; }
}
public class ResponseAutomationLocationRouteInfo
{
public string fixture { get; set; }
public string ordernumber { get; set; }
public string sn { get; set; }
public int location { get; set; }
public string productCode { get; set; }
public string route { get; set; }
public string pn { get; set; }
}
}
......@@ -276,6 +276,7 @@ CREATE TABLE IF NOT EXISTS `siger_automation_location` (
`sn` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工件',
`routeid` int(11) NULL DEFAULT 0,
`route` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工序',
`routenum` int(11) NULL DEFAULT 0 COMMENT '工序顺序',
`attachment` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件',
`filename` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '附件名称',
`remark` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
......
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