Commit 54b81565 by jiawei.su

someupdate AutoMes

parent dbfc3567
...@@ -17,6 +17,8 @@ using Siger.Middlelayer.Repository.Repositories.Interface; ...@@ -17,6 +17,8 @@ using Siger.Middlelayer.Repository.Repositories.Interface;
using Siger.Middlelayer.Share.Constant; using Siger.Middlelayer.Share.Constant;
using Siger.Middlelayer.Share.Enum.ModuleEnum; 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 NPOI.SS.Formula.Functions;
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
...@@ -31,9 +33,12 @@ namespace Siger.ApiACC.Controllers ...@@ -31,9 +33,12 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationTaskListRepository _automationTaskList; private readonly IAutomationTaskListRepository _automationTaskList;
private readonly ISigerProjectMachineAttributionRepository _sigerProjectMachineAttribution; private readonly ISigerProjectMachineAttributionRepository _sigerProjectMachineAttribution;
private readonly IAutomationFixtureMonitor _automationFixtureMonitor; private readonly IAutomationFixtureMonitor _automationFixtureMonitor;
private readonly IAutomationLocationRepository _automationLocation;
private readonly IProductionBeatSetRepository _productionBeatSet;
private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct;
public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList, public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList,
ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor) ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor, IAutomationLocationRepository automationLocation, IProductionBeatSetRepository productionBeatSet, IAutomationFixtureToolsProductRepository automationFixtureToolsProduct )
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
...@@ -43,8 +48,11 @@ namespace Siger.ApiACC.Controllers ...@@ -43,8 +48,11 @@ namespace Siger.ApiACC.Controllers
_automationTaskList = automationTaskList; _automationTaskList = automationTaskList;
_sigerProjectMachineAttribution = sigerProjectMachineAttribution; _sigerProjectMachineAttribution = sigerProjectMachineAttribution;
_automationFixtureMonitor = automationFixtureMonitor; _automationFixtureMonitor = automationFixtureMonitor;
_automationLocation = automationLocation;
_productionBeatSet = productionBeatSet;
_automationFixtureToolsProduct = automationFixtureToolsProduct;
} }
/// <summary> /// <summary>
/// 设备状态接口 用于 保存 设备当前可用状态 /// 设备状态接口 用于 保存 设备当前可用状态
/// </summary> /// </summary>
...@@ -76,6 +84,7 @@ namespace Siger.ApiACC.Controllers ...@@ -76,6 +84,7 @@ namespace Siger.ApiACC.Controllers
exitsObj.updatetime = DateTime.Now; exitsObj.updatetime = DateTime.Now;
} }
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
// 设备空闲,或者完成时触发 自动任务 // 设备空闲,或者完成时触发 自动任务
...@@ -86,11 +95,17 @@ namespace Siger.ApiACC.Controllers ...@@ -86,11 +95,17 @@ namespace Siger.ApiACC.Controllers
var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated); var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated);
if (!tasklist.Any()) if (!tasklist.Any())
{ {
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound);
}
var section = _sigerProjectLevelSection.Get(f => f.id == machineAttr.station); var section = _sigerProjectLevelSection.Get(f => f.id == machineAttr.station);
if (section != null) if (section != null)
{ {
Logger.WriteLineInfo($"MachineStatus 设备状态 触发自动任务检查"); Logger.WriteLineInfo($"MachineStatus 设备状态 触发自动任务检查");
AutoProcess(section.parentid); AutoProcess(section.parentid, stationDicts);
} }
} }
} }
...@@ -138,11 +153,19 @@ namespace Siger.ApiACC.Controllers ...@@ -138,11 +153,19 @@ namespace Siger.ApiACC.Controllers
//TODO //TODO
//手动-》自动 时 //手动-》自动 时
//task 无任务时候 ,根据设备状态创建任务 //task 无任务时候 ,根据设备状态创建任务
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound);
}
var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated); var tasklist = _automationTaskList.GetList(f => f.projectId == PID && f.status >= (int)TaskResultStatus.Cancel && f.status < (int)TaskResultStatus.Complated);
if (!tasklist.Any()) if (!tasklist.Any())
{ {
Logger.WriteLineInfo($"LineMode Mode=1 触发自动任务检查"); Logger.WriteLineInfo($"LineMode Mode=1 触发自动任务检查");
AutoProcess(line); AutoProcess(line, stationDicts);
} }
} }
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
...@@ -193,18 +216,14 @@ namespace Siger.ApiACC.Controllers ...@@ -193,18 +216,14 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.AutoTaskDone); throw new BadRequestException(AccEnum.AutoTaskDone);
} }
//2.更新状态 var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
taskObj.status = request.status; if (!stationDicts.Any())
_automationTaskList.Update(taskObj);
var machineStatus = _automationMachineStatus.Get(f => f.section == taskObj.sectionid);
if (machineStatus==null)
{ {
throw new BadRequestException(AccEnum.MachineDisable); Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound);
} }
//更新Tasklist
machineStatus.status = request.status; PlCfeeback(taskObj, request.status, stationDicts);
_automationMachineStatus.Update(machineStatus);
if (_unitOfWork.Commit() <= 0) if (_unitOfWork.Commit() <= 0)
{ {
...@@ -229,7 +248,7 @@ namespace Siger.ApiACC.Controllers ...@@ -229,7 +248,7 @@ namespace Siger.ApiACC.Controllers
var section = _sigerProjectLevelSection.Get(f => f.id == taskObj.sectionid); var section = _sigerProjectLevelSection.Get(f => f.id == taskObj.sectionid);
if (section != null) if (section != null)
{ {
AutoProcess(section.parentid); AutoProcess(section.parentid, stationDicts);
} }
break; break;
} }
...@@ -243,11 +262,93 @@ namespace Siger.ApiACC.Controllers ...@@ -243,11 +262,93 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
void PlCfeeback(siger_automation_task_list taskObj,int status, IEnumerable<SigerTrDict> stationDicts)
{
//2.更新状态
taskObj.status = status;
_automationTaskList.Update(taskObj);
var machineStatus = _automationMachineStatus.Get(f => f.section == taskObj.sectionid);
if (machineStatus == null)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
machineStatus.status = status;
_automationMachineStatus.Update(machineStatus);
//PLC 反馈结束. 工装监控 解除设备绑定
if (status == (int)TaskResultStatus.Complated)
{
var uploadStation = stationDicts.Where(f => f.dkey == DictKeyValConst.UploadloadStation);
var uploadStations = uploadStation.Select(f => f.dval).ToList();
if (taskObj.action == TaskAction.Step_SXLW_LK)
{
// 业务入口: 上料位-》 入库 如果是上料工装 安装完成 ,绑定 储位与装配
if (uploadStations.Exists(f => f.Contains(taskObj.sectionid.ToString())))
{
var location = _automationLocation.Get(f => f.fixturetools == taskObj.fixtureguid);
if (location == null)
{
location.ordernumber = taskObj.ordercode;
location.sn = taskObj.sn;
}
}
}
else if (taskObj.action == TaskAction.Step_LK_CJT || taskObj.action == TaskAction.Step_LK_JGZX || taskObj.action == TaskAction.Step_LK_SXLW)
{
//出库
var location = _automationLocation.Get(f => f.fixturetools == taskObj.fixtureguid);
if (location == null)
{
location.ordernumber = "";
location.sn = "";
}
//更新 CNC 状态
var monitor = _automationFixtureMonitor.Get(f => f.section==taskObj.sectionid);
if(monitor==null)
{
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
{
ordernumber=taskObj.ordercode,
productCode=taskObj.productcode,
//productNam
section=taskObj.sectionid,
status=status,
sn=taskObj.sn,
fixtureguid=taskObj.fixtureguid,
//fixturename=,
locationId=taskObj.locationid,
createtime=DateTime.Now,
projectId=PID,
route=0,
updatetime=DateTime.Now,
});
}else
{
monitor.ordernumber = taskObj.ordercode;
monitor.productCode = taskObj.productcode;
monitor.status = taskObj.status;
monitor.sn = taskObj.sn;
monitor.locationId = taskObj.locationid;
monitor.updatetime = DateTime.Now;
_automationFixtureMonitor.Update(monitor);
}
}
}
}
/// <summary> /// <summary>
/// 创建自动 Task任务 /// 创建自动 Task任务
/// </summary> /// </summary>
/// <param name="line"></param> /// <param name="line"></param>
void AutoProcess(int line) /// <param name="stationDicts"></param>
void AutoProcess(int line,IEnumerable<SigerTrDict> stationDicts)
{ {
var lineMode = _automationLineMode.Get(f => f.projectId == PID && f.section == line); var lineMode = _automationLineMode.Get(f => f.projectId == PID && f.section == line);
if (lineMode==null) if (lineMode==null)
...@@ -268,12 +369,7 @@ namespace Siger.ApiACC.Controllers ...@@ -268,12 +369,7 @@ namespace Siger.ApiACC.Controllers
//2.其他设备上料 //2.其他设备上料
//3.其他设备下料 //3.其他设备下料
*/ */
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any())
{
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
return;
}
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).ToList();
...@@ -301,8 +397,20 @@ namespace Siger.ApiACC.Controllers ...@@ -301,8 +397,20 @@ 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");
CreateTask(cleanMachine,TaskActionType.Unload, TaskAction.Step_QXJ_LK, uploadStations); 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);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
} }
...@@ -313,7 +421,19 @@ namespace Siger.ApiACC.Controllers ...@@ -313,7 +421,19 @@ namespace Siger.ApiACC.Controllers
if (freeMachine != null) if (freeMachine != null)
{ {
Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备上料Task"); Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备上料Task");
CreateTask(freeMachine,TaskActionType.Load ,TaskAction.Step_LK_JGZX, uploadStations); 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);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
//优先级3:其他设备下料 (加工中心 ->立库) //优先级3:其他设备下料 (加工中心 ->立库)
...@@ -323,7 +443,19 @@ namespace Siger.ApiACC.Controllers ...@@ -323,7 +443,19 @@ 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 ");
CreateTask(fullMachine,TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, uploadStations); 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);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
...@@ -338,28 +470,14 @@ namespace Siger.ApiACC.Controllers ...@@ -338,28 +470,14 @@ namespace Siger.ApiACC.Controllers
/// <param name="actionType"></param> /// <param name="actionType"></param>
/// <param name="taskAction"></param> /// <param name="taskAction"></param>
/// <param name="uploadStations"></param> /// <param name="uploadStations"></param>
void CreateTask(siger_automation_machine_status machineStatus,TaskActionType actionType, TaskAction taskAction,List<string>uploadStations) /// <param name="guid">工装GUID</param>
/// <param name="orderno">订单</param>
/// <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)
{ {
var uploadPostion= uploadStations.Exists(f => f.Contains(machineStatus.section.ToString()));
if (uploadPostion)
{
Logger.WriteLineInfo($"CreateTask 上料料工站 无需自动创建任务 ");
return;
}
//j检查工装监控状态
var monitor = _automationFixtureMonitor.Get(f => f.section == machineStatus.section);
if (monitor==null)
{
Logger.WriteLineInfo($"CreateTask 工装监控状态无数据,请确认业务链正确 ");
return;
}
if (monitor.section==0)
{
Logger.WriteLineInfo($"CreateTask 工装监控状态无当前工站信息,请确认业务链正确 ");
return;
}
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
projectId = PID, projectId = PID,
...@@ -374,11 +492,11 @@ namespace Siger.ApiACC.Controllers ...@@ -374,11 +492,11 @@ namespace Siger.ApiACC.Controllers
send = 0, send = 0,
operater = 0, operater = 0,
status = 1, status = 1,
fixtureguid=monitor.fixtureguid, fixtureguid= guid,
productcode=monitor.productCode, productcode= productCode,
locationid=monitor.locationId, locationid= locationid,
ordercode=monitor.ordernumber, ordercode= orderno,
sn=monitor.sn, sn= sn,
remark="自动任务" remark="自动任务"
}); });
...@@ -389,6 +507,34 @@ namespace Siger.ApiACC.Controllers ...@@ -389,6 +507,34 @@ namespace Siger.ApiACC.Controllers
else else
Logger.WriteLineInfo($"CreateTask 工站 失败"); Logger.WriteLineInfo($"CreateTask 工站 失败");
} }
/// <summary>
/// 自动匹配储位 储位 ->CNC
/// </summary>
siger_automation_location SelectLocation(int machine)
{
// 当前空闲设备能加工的产品
var beats = _productionBeatSet.GetList(f => f.projectID == PID && f.machineID == machine);
var productIds = beats.Select(f => f.product_name.ToInt()).ToList();
// 取产品交期最近的订单
var planOrder = _automationFixtureToolsProduct.GetDeliveryOrder(productIds, PID);
if (!planOrder.Any())
{
Logger.WriteLineInfo($"SelectLocation 未找到最近订单号信息");
return null;
}
var order = planOrder.FirstOrDefault();
var location = _automationLocation.GetList(f => f.projectId == PID && f.ordernumber== order.ordernumber && productIds.Contains(f.productid));
if (location==null)
{
Logger.WriteLineInfo($"SelectLocation 未找到最近交期订单号{order.ordernumber} 对应产品 {order.productName}的储位信息");
return null;
}
return location.FirstOrDefault();
}
......
...@@ -30,10 +30,11 @@ namespace Siger.ApiACC.Controllers ...@@ -30,10 +30,11 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationLocationRepository _autoLocationRepository; private readonly IAutomationLocationRepository _autoLocationRepository;
private readonly IAutomationFixtureMonitor _fixtureMonitor; private readonly IAutomationFixtureMonitor _fixtureMonitor;
private readonly IProductRouteRepository _routeRepository; private readonly IProductRouteRepository _routeRepository;
private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct;
public AutomationLocationController(IUnitOfWork unitOfWork, IAutomationFixtureToolsCategoryRepository toolsCategoryRepository, public AutomationLocationController(IUnitOfWork unitOfWork, IAutomationFixtureToolsCategoryRepository toolsCategoryRepository,
IAutomationFixtureToolsRepository toolsRepository, IAutomationLocationRepository autoLocationRepository, IAutomationFixtureToolsRepository toolsRepository, IAutomationLocationRepository autoLocationRepository,
IAutomationFixtureMonitor fixtureMonitor, IProductRouteRepository routeRepository) IAutomationFixtureMonitor fixtureMonitor, IProductRouteRepository routeRepository,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_toolsCategoryRepository = toolsCategoryRepository; _toolsCategoryRepository = toolsCategoryRepository;
...@@ -41,6 +42,7 @@ namespace Siger.ApiACC.Controllers ...@@ -41,6 +42,7 @@ namespace Siger.ApiACC.Controllers
_autoLocationRepository = autoLocationRepository; _autoLocationRepository = autoLocationRepository;
_fixtureMonitor = fixtureMonitor; _fixtureMonitor = fixtureMonitor;
_routeRepository = routeRepository; _routeRepository = routeRepository;
_automationFixtureToolsProduct = automationFixtureToolsProduct;
} }
[HttpGet] [HttpGet]
...@@ -192,6 +194,8 @@ namespace Siger.ApiACC.Controllers ...@@ -192,6 +194,8 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
} }
var fixturetoolProduct = _automationFixtureToolsProduct.Get(f => f.fixturetools == fixturetool.guid);
var location = _autoLocationRepository.GetLocation(req.locationid.ToInt(), ProjectId); var location = _autoLocationRepository.GetLocation(req.locationid.ToInt(), ProjectId);
if (location == null) if (location == null)
{ {
...@@ -209,6 +213,8 @@ namespace Siger.ApiACC.Controllers ...@@ -209,6 +213,8 @@ namespace Siger.ApiACC.Controllers
guid = Guid.NewGuid().ToString(), guid = Guid.NewGuid().ToString(),
locationid = location.locationid, locationid = location.locationid,
fixturetools = fixturetool.guid, fixturetools = fixturetool.guid,
productid= fixturetoolProduct != null ? fixturetoolProduct.productid : 0,
productcode = fixturetoolProduct!=null? fixturetoolProduct.productcode:"",
attachment = req.fileurl, attachment = req.fileurl,
filename = req.filename, filename = req.filename,
remark = req.remark, remark = req.remark,
...@@ -244,6 +250,7 @@ namespace Siger.ApiACC.Controllers ...@@ -244,6 +250,7 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
} }
var fixturetoolProduct = _automationFixtureToolsProduct.Get(f => f.fixturetools == fixturetool.guid);
var location = _autoLocationRepository.GetLocation(req.locationid.ToInt(), ProjectId); var location = _autoLocationRepository.GetLocation(req.locationid.ToInt(), ProjectId);
if (location == null) if (location == null)
{ {
...@@ -263,6 +270,9 @@ namespace Siger.ApiACC.Controllers ...@@ -263,6 +270,9 @@ namespace Siger.ApiACC.Controllers
entity.remark = req.remark; entity.remark = req.remark;
entity.updatetime = DateTime.Now; entity.updatetime = DateTime.Now;
entity.updator = UserId; entity.updator = UserId;
entity.productid = fixturetoolProduct != null ? fixturetoolProduct.productid : 0;
entity.productcode = fixturetoolProduct != null ? fixturetoolProduct.productcode : "";
_autoLocationRepository.Update(entity); _autoLocationRepository.Update(entity);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
......
...@@ -35,9 +35,10 @@ namespace Siger.ApiACC.Controllers ...@@ -35,9 +35,10 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationFixtureMonitor _automationFixtureMonitor; private readonly IAutomationFixtureMonitor _automationFixtureMonitor;
private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct; private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct;
private readonly IAutomationFixtureToolsRepository _automationFixtureTools; private readonly IAutomationFixtureToolsRepository _automationFixtureTools;
private readonly IAutomationLocationRepository _automationLocation;
public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList, public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList,
IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools) IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools, IAutomationLocationRepository automationLocation)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
...@@ -50,6 +51,7 @@ namespace Siger.ApiACC.Controllers ...@@ -50,6 +51,7 @@ namespace Siger.ApiACC.Controllers
_automationFixtureMonitor = automationFixtureMonitor; _automationFixtureMonitor = automationFixtureMonitor;
_automationFixtureToolsProduct = automationFixtureToolsProduct; _automationFixtureToolsProduct = automationFixtureToolsProduct;
_automationFixtureTools = automationFixtureTools; _automationFixtureTools = automationFixtureTools;
_automationLocation = automationLocation;
} }
/// <summary> /// <summary>
...@@ -173,7 +175,7 @@ namespace Siger.ApiACC.Controllers ...@@ -173,7 +175,7 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(result); return new ObjectResult(result);
} }
/// <summary> /// <summary>
/// 准备上料 -生成指令 load /// 准备上料 -生成指令 load (立库->上料位)
/// </summary> /// </summary>
/// <param name="loading"></param> /// <param name="loading"></param>
/// <returns></returns> /// <returns></returns>
...@@ -348,6 +350,8 @@ namespace Siger.ApiACC.Controllers ...@@ -348,6 +350,8 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(AccEnum.MonitorNotfound); throw new BadRequestException(AccEnum.MonitorNotfound);
} }
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
...@@ -376,7 +380,6 @@ namespace Siger.ApiACC.Controllers ...@@ -376,7 +380,6 @@ namespace Siger.ApiACC.Controllers
}); });
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
Logger.WriteLineError($"手动任务创建成功-{Siger.Middlelayer.Common.Helpers.EnumHelper.GetEnumDesc(Automation.TaskAction.Step_SXLW_LK)}"); Logger.WriteLineError($"手动任务创建成功-{Siger.Middlelayer.Common.Helpers.EnumHelper.GetEnumDesc(Automation.TaskAction.Step_SXLW_LK)}");
......
...@@ -38,5 +38,10 @@ namespace Siger.Middlelayer.Share.Constant ...@@ -38,5 +38,10 @@ namespace Siger.Middlelayer.Share.Constant
/// </summary> /// </summary>
public const string UploadloadStation = "LoadStation"; public const string UploadloadStation = "LoadStation";
/// <summary>
/// 立库
/// </summary>
public const string WarehouseStation = "WarehouseStation";
} }
} }
...@@ -334,7 +334,9 @@ namespace Siger.Middlelayer.Common.ModuleEnum ...@@ -334,7 +334,9 @@ namespace Siger.Middlelayer.Common.ModuleEnum
[Description("设备已经生产完成")] [Description("设备已经生产完成")]
MachineProCompalate, MachineProCompalate,
[Description("该设备当前无工装状态")] [Description("该设备当前无工装状态")]
MonitorNotfound MonitorNotfound,
[Description("未配置字典信息")]
AutomationDictNotfound
} }
public enum SeriNumCfg public enum SeriNumCfg
......
...@@ -18,6 +18,26 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -18,6 +18,26 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 工装GUID /// 工装GUID
/// </summary> /// </summary>
public string fixturetools { get; set; } public string fixturetools { get; set; }
public int productid { get; set; }
public string productcode { get; set; }
/// <summary>
/// 工件对应的工单号
/// </summary>
public string ordernumber { get; set; }
/// <summary>
/// 工装工件
/// </summary>
public string sn { get; set; }
/// <summary>
/// 每加工CNC 设备 经过的工序: 标准节拍表
/// </summary>
public int routeid { get; set; }
/// <summary>
/// 每加工CNC 设备 经过的工序: 标准节拍表
/// </summary>
public string route { get; set; }
/// <summary> /// <summary>
/// 附件 /// 附件
/// </summary> /// </summary>
......
...@@ -97,6 +97,27 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -97,6 +97,27 @@ namespace Siger.Middlelayer.AccRepository.Repositories
} }
} }
/// <summary>
/// 获取 交期最早的订单
/// </summary>
/// <param name="productIds"></param>
/// <param name="projectId"></param>
/// <returns></returns>
public IEnumerable<ResponseAutomationPlanOrder> GetDeliveryOrder(List<int>productIds,int projectId)
{
var query = from d in _context.siger_project_product_plan_detail
join p in _context.siger_project_product_plan on d.PlanId equals p.id
where d.projectId == projectId && productIds.Contains(p.product_id) && d.status != (int)RowState.Invalid && p.status != (int)RowState.Invalid
select new ResponseAutomationPlanOrder
{
ordernumber=d.OrderNumber,
productCode=p.product_code,
productName=p.product_name,
delvery=p.delivery_time,
};
return query.OrderBy(f => f.delvery);
}
public ResponsePlanlFixtureInfo GetPlanFixtureInfo(int projectId, string ordernumber) public ResponsePlanlFixtureInfo GetPlanFixtureInfo(int projectId, string ordernumber)
{ {
......
...@@ -23,5 +23,13 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -23,5 +23,13 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
CommonImportResult ImportData(IEnumerable<FixtureToolsProductTemplate> list, int projectid, int userid); CommonImportResult ImportData(IEnumerable<FixtureToolsProductTemplate> list, int projectid, int userid);
/// <summary>
/// 获取交期最近的订单
/// </summary>
/// <param name="productIds"></param>
/// <param name="projectId"></param>
/// <returns></returns>
IEnumerable<ResponseAutomationPlanOrder> GetDeliveryOrder(List<int> productIds, int projectId);
} }
} }
...@@ -40,4 +40,13 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -40,4 +40,13 @@ namespace Siger.Middlelayer.AccRepository.Response
public int Location { get; set; } public int Location { get; set; }
public string Sn { get; set; } public string Sn { get; set; }
} }
public class ResponseAutomationPlanOrder
{
public string ordernumber { get; set; }
public string productCode { get; set; }
public string productName { get; set; }
public int delvery { get; set; }
}
} }
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