예제 #1
0
        public DataResult GetDeviceSchedule()
        {
            var result     = new DataResult();
            var deviceList = SmartDeviceHelper.Instance.GetAll <SmartDevice>();
            var categories = SmartDeviceCategoryHelper.Instance.GetAll <SmartDeviceCategory>();
            var devices    = SimulateHelper.Devices();
            var data       = new List <SmartProcessDeviceDetail>();

            data.AddRange(devices.Select(ClassExtension.ParentCopyToChild <SmartProcessDevice, SmartProcessDeviceDetail>));
            foreach (var device in data)
            {
                var d = deviceList.FirstOrDefault(x => x.Id == device.Id);
                if (d != null)
                {
                    device.Code = d.Code;
                }
                var c = categories.FirstOrDefault(x => x.Id == device.CategoryId);
                if (c != null)
                {
                    device.Category = c.Category;
                }
            }
            var processId = devices.SelectMany(x => x.NextProcesses.Select(y => y.Item1));

            if (processId.Any())
            {
                var flowCards = ServerConfig.ApiDb.Query <SmartFlowCardProcessDetail>(
                    "SELECT a.Id, b.FlowCard, a.`Before`, a.`Qualified`, a.`Unqualified` FROM `t_flow_card_process` a " +
                    "JOIN `t_flow_card` b ON a.FlowCardId = b.Id WHERE a.MarkedDelete = 0 AND a.Id IN @processId;",
                    new { processId });

                foreach (var device in data)
                {
                    foreach (var process in device.NextProcesses)
                    {
                        var flowCard = flowCards.FirstOrDefault(x => x.Id == process.Item1);
                        if (flowCard != null)
                        {
                            device.NextProcess.Add(new Tuple <string, string>(flowCard.FlowCard, flowCard.DeliveryTime.ToStr()));
                        }
                    }
                }
            }
            result.datas.AddRange(data);
            return(result);
        }
예제 #2
0
 public void Initialize(ProjectModel pmodel)
 {
     SimulateHelper.Simulate(pmodel);
 }