public Result ReportSmartFlowCardProcess([FromBody] SmartFlowCardProcess flowCardProcess) { var process = SmartFlowCardProcessHelper.Instance.Get <SmartFlowCardProcess>(flowCardProcess.Id); if (process == null) { return(Result.GenError <Result>(Error.SmartFlowCardProcessNotExist)); } var userId = Request.GetIdentityInformation(); var markedDateTime = DateTime.Now; var wId = flowCardProcess.WorkshopId; flowCardProcess.CreateUserId = userId; flowCardProcess.MarkedDateTime = markedDateTime; process.Count++; process.Qualified += flowCardProcess.Qualified; process.Unqualified += flowCardProcess.Unqualified; process.ProcessorId = flowCardProcess.ProcessorId; process.DeviceId = flowCardProcess.DeviceId; SmartFlowCardProcessHelper.Instance.Update(flowCardProcess); SmartFlowCardProcessLogHelper.Instance.Add(new SmartFlowCardProcessLog(wId, userId, markedDateTime, process, process.Qualified, process.Unqualified)); OldWorkFlowHelper.Instance.OnSmartFlowCardProcessChanged(new List <SmartFlowCardProcess> { flowCardProcess }); return(Result.GenError <Result>(Error.Success)); }
public object PostSmartFlowCard([FromBody] IEnumerable <SmartFlowCard> flowCards) { if (flowCards == null || !flowCards.Any()) { return(Result.GenError <Result>(Error.ParamError)); } if (flowCards.Count(x => x.Number <= 0) > 1) { return(Result.GenError <Result>(Error.SmartFlowCardNumberError)); } var wId = flowCards.First().WorkshopId; var taskOrderId = flowCards.First().TaskOrderId; if (flowCards.GroupBy(x => x.ProcessCodeId).Count() > 1) { return(Result.GenError <Result>(Error.ParamError)); } var processCodeId = flowCards.First().ProcessCodeId; var thisTotal = flowCards.Sum(x => x.Number); var taskOrder = SmartTaskOrderHelper.Instance.Get <SmartTaskOrder>(taskOrderId); if (taskOrder == null) { return(Result.GenError <Result>(Error.SmartTaskOrderNotExist)); } if (taskOrder.Left <= 0) { return(Result.GenError <Result>(Error.SmartFlowCardNumberLimit)); } var processes = SmartProductProcessHelper.GetSmartProductProcesses(taskOrderId, processCodeId); if (!processes.Any()) { return(Result.GenError <Result>(Error.SmartProcessNotEmpty)); } var batch = SmartFlowCardHelper.GetSmartFlowCardBatch(taskOrderId); batch++; var count = flowCards.Count(); var userId = Request.GetIdentityInformation(); var markedDateTime = DateTime.Now; var fcs = CodeHelper.GenCodes(CodeType.流程卡, count, markedDateTime).ToArray(); var i = 0; foreach (var flowCard in flowCards) { flowCard.CreateUserId = userId; flowCard.MarkedDateTime = markedDateTime; flowCard.CreateTime = markedDateTime; flowCard.FlowCard = fcs[i]; flowCard.Batch = batch; flowCard.Remark = flowCard.Remark ?? ""; i++; } SmartFlowCardHelper.Instance.Add(flowCards); var addFlowCards = SmartFlowCardHelper.GetSmartFlowCardsByBatch(taskOrderId, batch); var smartFlowCardProcesses = new List <SmartFlowCardProcess>(); i = 0; foreach (var smartFlowCard in addFlowCards) { var newSmartFlowCard = flowCards.ElementAt(i); smartFlowCard.ProcessorId = newSmartFlowCard.ProcessorId; var t = true; foreach (var process in processes) { var flowCardProcess = new SmartFlowCardProcess { CreateUserId = userId, MarkedDateTime = markedDateTime, WorkshopId = wId, FlowCardId = smartFlowCard.Id, ProcessId = process.Id, }; if (t) { flowCardProcess.ProcessorId = smartFlowCard.ProcessorId; flowCardProcess.Before = smartFlowCard.Number; t = false; } smartFlowCardProcesses.Add(flowCardProcess); } i++; } SmartFlowCardProcessHelper.Instance.Add <SmartFlowCardProcess>(smartFlowCardProcesses); taskOrder.Doing += thisTotal; taskOrder.Issue += count; taskOrder.MarkedDateTime = markedDateTime; OldWorkFlowHelper.Instance.OnSmartFlowCardChanged(addFlowCards); OldWorkFlowHelper.Instance.OnSmartFlowCardProcessCreated(addFlowCards, smartFlowCardProcesses); return(new { errno = 0, errmsg = "成功", taskOrder.Target, taskOrder.Left, taskOrder.Doing, taskOrder.Issue, FlowCards = addFlowCards }); }