Commit 8c5d4f65 by yiyu.li
parents f5fa1526 ee54ef29
...@@ -2101,6 +2101,14 @@ export default { ...@@ -2101,6 +2101,14 @@ export default {
'3000166': '未配置字典信息', '3000166': '未配置字典信息',
'3000167': '产线当前为自动模式', '3000167': '产线当前为自动模式',
'3000168': '该任务已经下发', '3000168': '该任务已经下发',
'3000169': '该储位无工件',
'3000170': '工站属性为空',
'3000171': '该储位已存在工件',
'3000172': '该工站正在上料中',
'3000173': '该工站正在下料中',
'3000174': '储位不存在',
'3000175': '工序加工未完成',
'3000176': '工序未开始加工',
'400000': '设备状态', '400000': '设备状态',
'400002': '更改状态', '400002': '更改状态',
......
...@@ -22,6 +22,7 @@ using NPOI.SS.Formula.Functions; ...@@ -22,6 +22,7 @@ using NPOI.SS.Formula.Functions;
using Siger.Middlelayer.AccRepository.Response; using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
using NPOI.SS.Formula; using NPOI.SS.Formula;
using NPOI.OpenXml4Net.OPC.Internal;
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
...@@ -551,17 +552,24 @@ namespace Siger.ApiACC.Controllers ...@@ -551,17 +552,24 @@ namespace Siger.ApiACC.Controllers
} }
else else
{ {
//优先级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");
var monitorClean = _automationFixtureMonitor.Get(f => f.section == cleanMachine.section);
if (monitorClean!=null)
{
if (string.IsNullOrEmpty(monitorClean.sn))
{
Logger.WriteLineError($"AutoProcess 清洗机完成,清洗监控无工件");
}else
{
//取最近完成的 Task //取最近完成的 Task
var lastTask = _automationTaskList.GetList(f => f.sectionid == cleanMachine.section, "id", true).FirstOrDefault(); var lastTask = _automationTaskList.GetList(f => f.sectionid == cleanMachine.section, "id", true).FirstOrDefault();
if (lastTask != null) if (lastTask != null)
{ {
if(lastTask.action== TaskAction.Step_QXJ_LK) if (lastTask.action == TaskAction.Step_QXJ_LK)
{ {
Logger.WriteLineError($"AutoProcess 清洗机完成,上一个任务与本次任务指令重复"); Logger.WriteLineError($"AutoProcess 清洗机完成,上一个任务与本次任务指令重复");
return; //任务重复 return; //任务重复
...@@ -578,6 +586,9 @@ namespace Siger.ApiACC.Controllers ...@@ -578,6 +586,9 @@ namespace Siger.ApiACC.Controllers
} }
} }
} }
}
}
//优先级2 :其他设备待上料 (立库->加工中心) //优先级2 :其他设备待上料 (立库->加工中心)
var freeMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Waiting); var freeMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Waiting);
if (freeMachine != null) if (freeMachine != null)
...@@ -602,7 +613,7 @@ namespace Siger.ApiACC.Controllers ...@@ -602,7 +613,7 @@ namespace Siger.ApiACC.Controllers
//优先级3:其他设备下料 (加工中心 ->清洗机) //优先级3:其他设备下料 (加工中心 ->清洗机)
if (cleanMachine != null) if (cleanMachine != null)
{ {
siger_automation_machine_status fullMachine = null; //siger_automation_machine_status fullMachine = null;
var fullAllMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Complated); var fullAllMachine = machineStatusList.Where(f => f.status == (int)Automation.MachineStatus.Complated);
if (fullAllMachine.Any() && cleanMachine.status == (int)Automation.MachineStatus.Waiting) if (fullAllMachine.Any() && cleanMachine.status == (int)Automation.MachineStatus.Waiting)
...@@ -611,7 +622,7 @@ namespace Siger.ApiACC.Controllers ...@@ -611,7 +622,7 @@ namespace Siger.ApiACC.Controllers
//清洗机上料 为 任务触发 触发 //清洗机上料 为 任务触发 触发
if (tasklist != null && fullAllMachine.Where(p => p.section == tasklist.sectionid).Any()) if (tasklist != null && fullAllMachine.Where(p => p.section == tasklist.sectionid).Any())
{ {
fullMachine = fullAllMachine.Where(p => p.section == tasklist.sectionid).FirstOrDefault(); var fullMachine = fullAllMachine.Where(p => p.section == tasklist.sectionid).FirstOrDefault();
Logger.WriteLineError($"AutoProcess 清洗机空闲,TaskResult触发 "); Logger.WriteLineError($"AutoProcess 清洗机空闲,TaskResult触发 ");
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {tasklist.sn}"); Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {tasklist.sn}");
...@@ -631,24 +642,26 @@ namespace Siger.ApiACC.Controllers ...@@ -631,24 +642,26 @@ namespace Siger.ApiACC.Controllers
} }
else else
{ {
var fullmids = fullAllMachine.Select(s => s.section).ToList();
fullMachine = fullAllMachine.First(); var lastMonitorItem = _automationFixtureMonitor.GetList(p => fullmids.Contains(p.section) && !string.IsNullOrEmpty(p.sn)).OrderByDescending(p => p.id).FirstOrDefault();
if (_automationTaskList.CanTask(PID, fullMachine.section)) if (lastMonitorItem==null)
{ {
Logger.WriteLineError($"AutoProcess 清洗机空闲,MachineStatus触发 "); Logger.WriteLineError($"AutoProcess 清洗机空闲,设备监控无可下料的设备 ");
var lastMonitorItem = _automationFixtureMonitor.GetList(p => p.section == fullMachine.section).OrderByDescending(p => p.id).FirstOrDefault(); return;
if (lastMonitorItem != null) }
if (_automationTaskList.CanTask(PID, lastMonitorItem.section))
{ {
var lastTask = _automationTaskList.GetList(f => f.sectionid == fullMachine.section && f.sn == lastMonitorItem.sn && f.status == (int)Automation.TaskResultStatus.Complated, "id", true).FirstOrDefault(); Logger.WriteLineError($"AutoProcess 清洗机空闲,MachineStatus触发 ");
var lastTask = _automationTaskList.GetList(f => f.sectionid == lastMonitorItem.section && f.sn == lastMonitorItem.sn && f.status == (int)Automation.TaskResultStatus.Complated, "id", true).FirstOrDefault();
if (lastTask != null) if (lastTask != null)
{ {
Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{fullMachine.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {lastTask.sn}"); Logger.WriteLineInfo($"自动化业务流转--AutoProcess section{lastMonitorItem.section} task:{TaskAction.Step_JGZX_QXJ.ToStr()} sn {lastTask.sn}");
if (TargetFree(cleanMachine.section, fullMachine.section, TaskAction.Step_JGZX_QXJ)) if (TargetFree(cleanMachine.section, lastMonitorItem.section, TaskAction.Step_JGZX_QXJ))
{ {
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); CreateTask(cleanMachine.section, lastMonitorItem.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);
}
} }
} }
} }
} }
} }
...@@ -716,9 +729,21 @@ namespace Siger.ApiACC.Controllers ...@@ -716,9 +729,21 @@ namespace Siger.ApiACC.Controllers
{ {
// 当前空闲设备能加工的产品 // 当前空闲设备能加工的产品
var beats = _productionBeatSet.GetList(f => f.projectID == PID && machines.Contains(f.machineID) && f.status == (int)RowState.Valid).ToList(); var beats = _productionBeatSet.GetList(f => f.projectID == PID && machines.Contains(f.machineID) && f.status == (int)RowState.Valid).ToList();
var TempList = new List<ResponseAutoRouteInfo>(); var TempList = new List<ResponseAutoRouteInfo>();
foreach (var b in beats) foreach (var b in beats)
{ {
var moniter = _automationFixtureMonitor.Get(f => f.section ==b.section_id);
if (moniter != null)
{
//防错 监控设备中无SN 加工的工站
if (!string.IsNullOrEmpty(moniter.sn))
{
Logger.WriteLineInfo($"CreateTask machineId:{b.machineID} 设备上有SN在加工");
continue;
}
}
Logger.WriteLineError($"SelectLocation 设备{b.machineID}标准节拍{b.route_number}{b.route_name}"); Logger.WriteLineError($"SelectLocation 设备{b.machineID}标准节拍{b.route_number}{b.route_name}");
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())
......
...@@ -361,10 +361,10 @@ namespace Siger.ApiACC.Controllers ...@@ -361,10 +361,10 @@ namespace Siger.ApiACC.Controllers
[HttpGet] [HttpGet]
public IActionResult GetLocationList(string productcode, int fillsn=0) public IActionResult GetLocationList(string productcode, int fillsn=0)
{ {
var productFix = _automationFixtureToolsProduct.Get(f => f.productcode == productcode); // var productFix = _automationFixtureToolsProduct.Get(f => f.productcode == productcode);
var locations = _autoLocationRepository.GetFulllocation(ProjectId, fillsn); var locations = _autoLocationRepository.GetFulllocation(ProjectId, fillsn,productcode);
return new ObjectResult(locations); return new ObjectResult(locations);
//if (fillsn == 1) //if (fillsn == 1)
//{ //{
......
...@@ -45,10 +45,11 @@ namespace Siger.ApiACC.Controllers ...@@ -45,10 +45,11 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationLineMode _automationLine; private readonly IAutomationLineMode _automationLine;
private readonly IProductRouteRepository _productRoute; private readonly IProductRouteRepository _productRoute;
private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository; private readonly IAutomationSectionPropertyRepository _sectionPropertyRepository;
private readonly IAutomationProduceHistoryRepository _automationProduceHistory;
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, IAutomationLocationRepository automationLocation, IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools, IAutomationLocationRepository automationLocation,
IAutomationLineMode automationLine, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository sectionPropertyRepository) IAutomationLineMode automationLine, IProductRouteRepository productRoute, IAutomationSectionPropertyRepository sectionPropertyRepository,IAutomationProduceHistoryRepository automationProduceHistory)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
...@@ -65,6 +66,7 @@ namespace Siger.ApiACC.Controllers ...@@ -65,6 +66,7 @@ namespace Siger.ApiACC.Controllers
_automationLine = automationLine; _automationLine = automationLine;
_productRoute = productRoute; _productRoute = productRoute;
_sectionPropertyRepository = sectionPropertyRepository; _sectionPropertyRepository = sectionPropertyRepository;
_automationProduceHistory = automationProduceHistory;
} }
/// <summary> /// <summary>
...@@ -320,7 +322,15 @@ namespace Siger.ApiACC.Controllers ...@@ -320,7 +322,15 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.TaskProcessing); throw new BadRequestException(AccEnum.TaskProcessing);
} }
var location = _automationLocation.Get(f => f.locationid == loading.locationid);
if (location==null)
{
throw new BadRequestException(AccEnum.LocationNoExits);
}
if (!string.IsNullOrEmpty(location.sn))
{
throw new BadRequestException(AccEnum.LocationSnExits);
}
var plandts = _planDetails.Get(f => f.projectId == ProjectId && f.OrderNumber == loading.code); var plandts = _planDetails.Get(f => f.projectId == ProjectId && f.OrderNumber == loading.code);
if (plandts==null) if (plandts==null)
{ {
...@@ -543,6 +553,17 @@ namespace Siger.ApiACC.Controllers ...@@ -543,6 +553,17 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.LocationNoSn); throw new BadRequestException(AccEnum.LocationNoSn);
} }
if (location.routeid!=0)
{
throw new BadRequestException(AccEnum.RouteProcessing);
}else
{
var historys = _automationProduceHistory.GetList(f => f.sn == location.sn);
if (!historys.Any())
{
throw new BadRequestException(AccEnum.RouteNotStart);
}
}
var levelSection = _sigerProjectLevelSection.Get(f => f.id == unloading.section); var levelSection = _sigerProjectLevelSection.Get(f => f.id == unloading.section);
var lineMode = _automationLine.Get(f => f.section ==levelSection.parentid); var lineMode = _automationLine.Get(f => f.section ==levelSection.parentid);
if (lineMode==null) if (lineMode==null)
......
...@@ -351,7 +351,13 @@ namespace Siger.Middlelayer.Common.ModuleEnum ...@@ -351,7 +351,13 @@ namespace Siger.Middlelayer.Common.ModuleEnum
[Description("该工站正在上料中")] [Description("该工站正在上料中")]
Uploading, Uploading,
[Description("该工站正在下料中")] [Description("该工站正在下料中")]
Downloading Downloading,
[Description("储位不存在")]
LocationNoExits,
[Description("工序加工未完成")]
RouteProcessing,
[Description("工序未开始加工")]
RouteNotStart
} }
public enum SeriNumCfg public enum SeriNumCfg
......
...@@ -130,6 +130,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -130,6 +130,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join pd in _context.siger_project_product on p.product_id equals pd.id join pd in _context.siger_project_product on p.product_id equals pd.id
where q.projectId == projectId && d.OrderNumber == ordernumber where q.projectId == projectId && d.OrderNumber == ordernumber
&& q.status == (int)RowState.Valid && t.status == (int)RowState.Valid && l.status==(int)RowState.Valid && q.status == (int)RowState.Valid && t.status == (int)RowState.Valid && l.status==(int)RowState.Valid
&& string.IsNullOrEmpty(l.sn)
select new ResponsePlanlFixtureInfo select new ResponsePlanlFixtureInfo
{ {
OrderNumber = ordernumber, OrderNumber = ordernumber,
......
...@@ -101,8 +101,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -101,8 +101,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
var query = from q in _context.siger_automation_location var query = from q in _context.siger_automation_location
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid
join c in _context.siger_automation_fixture_tools_category on t.category equals c.guid join c in _context.siger_automation_fixture_tools_category on t.category equals c.guid
join tp in _context.siger_automation_fixture_tools_product on t.guid equals tp.fixturetools into tptemp join tp in _context.siger_automation_fixture_tools_product on t.guid equals tp.fixturetools
from tp in tptemp.DefaultIfEmpty()
join l in _context.siger_wms_storage_location on q.location_cid equals l.id join l in _context.siger_wms_storage_location on q.location_cid equals l.id
join w in _context.siger_wms_storage on l.storageid equals w.id join w in _context.siger_wms_storage on l.storageid equals w.id
where q.projectId == projectid && q.status == (int)RowState.Valid where q.projectId == projectid && q.status == (int)RowState.Valid
...@@ -122,7 +121,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -122,7 +121,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories
name = t.name, name = t.name,
materialsn = q.sn ?? "", materialsn = q.sn ?? "",
categoryid = c == null ? 0 : c.id, categoryid = c == null ? 0 : c.id,
productcode=tp!=null?tp.productcode:"" productcode=tp.productcode,
routeid=q.routeid,
route=q.route
}; };
Expression<Func<ResponseAutomationLocationList, bool>> locationidExpression = f => true; Expression<Func<ResponseAutomationLocationList, bool>> locationidExpression = f => true;
if (hasMaterial != 0) if (hasMaterial != 0)
...@@ -238,19 +239,21 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -238,19 +239,21 @@ namespace Siger.Middlelayer.AccRepository.Repositories
} }
} }
public IEnumerable<ResponseAutomationLocationList> GetFulllocation(int projectId,int full) public IEnumerable<ResponseAutomationLocationList> GetFulllocation(int projectId, int full, string productCode)
{ {
//获取有SN 的储位 //获取有SN 的储位
if (full==1)
{
var query = from q in _context.siger_automation_location var query = from q in _context.siger_automation_location
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid
join tp in _context.siger_automation_fixture_tools_product on t.guid equals tp.fixturetools
join l in _context.siger_wms_storage_location on q.location_cid equals l.id join l in _context.siger_wms_storage_location on q.location_cid equals l.id
join w in _context.siger_wms_storage on l.storageid equals w.id join w in _context.siger_wms_storage on l.storageid equals w.id
where q.projectId == projectId && !string.IsNullOrEmpty(q.sn) join r in _context.siger_project_product_route on q.routeid equals r.id into rtemp
&& q.status == (int)RowState.Valid&& t.status == (int)RowState.Valid from r in rtemp.DefaultIfEmpty()
where q.projectId == projectId
&& q.status == (int)RowState.Valid && t.status == (int)RowState.Valid
&& l.status == (int)RowState.Valid && w.status == (int)RowState.Valid && l.status == (int)RowState.Valid && w.status == (int)RowState.Valid
&& q.routeid==0
select new ResponseAutomationLocationList select new ResponseAutomationLocationList
{ {
id = q.id, id = q.id,
...@@ -265,39 +268,27 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -265,39 +268,27 @@ namespace Siger.Middlelayer.AccRepository.Repositories
fixturetoolid = t.id, fixturetoolid = t.id,
code = t.code, code = t.code,
name = t.name, name = t.name,
materialsn = q.sn materialsn = q.sn,
productcode = tp.productcode,
routeid = q.routeid,
route = r!=null?r.name:""
}; };
Expression<Func<ResponseAutomationLocationList, bool>> locationidExpression = f => true; Expression<Func<ResponseAutomationLocationList, bool>> locationidFullExpression = f => true;
return query.Where(locationidExpression); if (full == 1)
{
locationidFullExpression = f => !string.IsNullOrEmpty(f.materialsn);
}else }else
{ {
//选择SN为空的储位 locationidFullExpression = f => string.IsNullOrEmpty(f.materialsn);
var query = from q in _context.siger_automation_location }
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid Expression<Func<ResponseAutomationLocationList, bool>> productExpression = f => true;
join l in _context.siger_wms_storage_location on q.location_cid equals l.id if (!string.IsNullOrEmpty(productCode))
join w in _context.siger_wms_storage on l.storageid equals w.id
where q.projectId == projectId && string.IsNullOrEmpty(q.sn)
&& q.status == (int)RowState.Valid && t.status == (int)RowState.Valid
&& l.status == (int)RowState.Valid&& w.status == (int)RowState.Valid
select new ResponseAutomationLocationList
{ {
id = q.id, productExpression = f => f.productcode.Contains(productCode);
typeid = t.id,
fixtureguid = t.guid,
locationid = l.locationid,
location = l.realname,
locationcode = l.serial_number,
wavehouseid = w.id,
wavehouse = w.name,
wavehousecode = w.serial_number,
fixturetoolid = t.id,
code = t.code,
name = t.name,
materialsn = q.sn
};
Expression<Func<ResponseAutomationLocationList, bool>> locationidExpression = f => true;
return query.Where(locationidExpression);
} }
var expression = locationidFullExpression.And(productExpression);
return query.Where(expression);
} }
} }
......
...@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
CommonImportResult ImportData(IEnumerable<AutomationLocationTemplate> list, int projectid, int userid); CommonImportResult ImportData(IEnumerable<AutomationLocationTemplate> list, int projectid, int userid);
IEnumerable<ResponseAutomationLocationList> GetFulllocation(int projectId, int full); IEnumerable<ResponseAutomationLocationList> GetFulllocation(int projectId, int full,string productcode);
} }
} }
...@@ -105,5 +105,7 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -105,5 +105,7 @@ namespace Siger.Middlelayer.AccRepository.Response
public int categoryid { get; set; } public int categoryid { get; set; }
//产品CODE //产品CODE
public string productcode { get; set; } public string productcode { get; set; }
public int routeid { get; set; }
public string route { 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