public DataResult GetFlowCardLine([FromQuery] int qId) { var result = new DataResult(); //流程卡 var flowCard = SmartFlowCardHelper.Instance.Get <SmartFlowCard>(qId); if (flowCard == null) { return(result); } //流程卡流程错误 var processFaults = SmartProcessFaultHelper.GetSmartProcessFaultDetails(qId); //流程卡流程 var smartFlowCardProcesses = SmartLineFlowCardHelper.GetSmartLineFlowCardsByFlowCardId(qId); foreach (var processFault in processFaults) { var process = smartFlowCardProcesses.FirstOrDefault(x => x.ProcessId == processFault.ProcessId); process.Faults.Add(processFault); } result.datas.Add(smartFlowCardProcesses); return(result); }
public DataResult GetWorkOrderLine([FromQuery] int qId) { var result = new DataResult(); //工单 var workOrder = SmartWorkOrderHelper.Instance.Get <SmartWorkOrder>(qId); if (workOrder == null) { result.errno = Error.SmartWorkOrderNotExist; return(result); } //工单生产线 标准流程 var smartLineWorkOrders = SmartLineWorkOrderHelper.GetSmartLineWorkOrderDetailsByWorkOrderId(qId); if (!smartLineWorkOrders.Any()) { return(result); } //流程卡 var flowCards = SmartFlowCardHelper.GetSmartFlowCardsByWorkOrderId(qId); if (!flowCards.Any()) { return(result); } //流程编号id var processCodeIds = flowCards.Select(x => x.ProcessCodeId); //流程编号 var processCodes = SmartProcessCodeHelper.Instance.GetByIds <SmartProcessCode>(processCodeIds); if (!processCodes.Any()) { return(result); } //流程卡id var flowCardIds = flowCards.Select(x => x.Id); //流程卡流程错误 var processFaults = SmartProcessFaultHelper.GetSmartProcessFaultDetailsByFlowCardIds(flowCardIds); //标准生产线 var tempLines = smartLineWorkOrders.GroupBy(x => x.ProcessCodeCategoryId).ToDictionary(x => x.Key); foreach (var processFault in processFaults) { var processCodeId = flowCards.FirstOrDefault(x => x.Id == processFault.FlowCardId)?.ProcessCodeId ?? 0; if (processCodeId == 0) { continue; } var processCodeCategoryId = processCodes.FirstOrDefault(x => x.Id == processCodeId)?.CategoryId ?? 0; if (processCodeCategoryId == 0) { continue; } if (!tempLines.ContainsKey(processCodeCategoryId)) { continue; } var line = tempLines[processCodeCategoryId]; var process = line.FirstOrDefault(x => x.ProcessId == processFault.ProcessId); process.Faults.Add(processFault); } var lines = new List <SmartWorkOrderLine>(); foreach (var tempLine in tempLines) { var line = new SmartWorkOrderLine(); line.Processes.AddRange(tempLine.Value); lines.Add(line); } result.datas.AddRange(lines); return(result); }