Commit c93d78c5 by jiawei.su

someupdate

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