Exemple #1
0
        public static string InsertMachine_YieldAndMachineConfig(List <Machine_YieldDTO> Machine_YieldDTOs, List <Machine_Schedule_ConfigDTO> Machine_Schedule_ConfigDTOs)
        {
            MachineYieldReportService machineYieldReportService = new MachineYieldReportService(
                new Machine_YieldRepository(_DatabaseFactory),
                new UnitOfWork(_DatabaseFactory),
                new Machine_Schedule_ConfigRepository(_DatabaseFactory),
                new Machine_StationRepository(_DatabaseFactory),
                new Machine_CustomerRepository(_DatabaseFactory)
                );

            return(machineYieldReportService.InsertMachine_YieldAndMachineConfig(Machine_YieldDTOs, Machine_Schedule_ConfigDTOs));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            MachineYieldReportService machineYieldReportService = new MachineYieldReportService(
                new Machine_YieldRepository(_DatabaseFactory),
                new UnitOfWork(_DatabaseFactory),
                new Machine_Schedule_ConfigRepository(_DatabaseFactory),
                new Machine_StationRepository(_DatabaseFactory),
                new Machine_CustomerRepository(_DatabaseFactory)

                );
            MES_PIS_SyncFailedRecordService SyncFailedLogServer = new MES_PIS_SyncFailedRecordService
                                                                  (
                new MES_PIS_SyncFailedRecordRepository(_DatabaseFactory),
                new UnitOfWork(_DatabaseFactory)
                                                                  );

            LogMessageRecordService Log_Service = new LogMessageRecordService
                                                  (
                new UnitOfWork(_DatabaseFactory),
                new LogMessageRecodeRepository(_DatabaseFactory)
                                                  );

            _LogService          = Log_Service;
            _SyncFailedLogServer = SyncFailedLogServer;
            //获取站点配置参数。
            var      machine_Schedule_ConfigDTOs = machineYieldReportService.GetMachine_Schedule_ConfigDTO();
            DateTime datetime = DateTime.Now;
            // DateTime datetime =Convert.ToDateTime("2018-05-18 14:20");
            // DateTime datetime = Convert.ToDateTime("2018-05-14 13:20");

            var nomachine_Schedule_ConfigDTOs = machineYieldReportService.GetNOMachine_Schedule_ConfigDTO();
            var timeQuantum = GetTimeQuantum(datetime);

            //获取到的时候得到的数据,及有过排程的时候。
            if (machine_Schedule_ConfigDTOs.Count > 0)
            {
                //循环站点数据
                foreach (var item in machine_Schedule_ConfigDTOs)
                {
                    if (item.EndTime == timeQuantum.StartTime)
                    {
                        //30分钟
                        SetMachine_Yield(timeQuantum.StartTime, item.MES_Customer_Name, item.MES_Station_Name, 1, item.Machine_Station_UID);
                    }
                    else if (item.EndTime == timeQuantum.StartTime.AddMinutes(-30))
                    {
                        //60分钟调用2次
                        SetMachine_Yield(timeQuantum.StartTime.AddMinutes(-30), item.MES_Customer_Name, item.MES_Station_Name, 2, item.Machine_Station_UID);
                    }
                    else if (item.EndTime == timeQuantum.StartTime.AddMinutes(-60))
                    {
                        //90分钟调用3次
                        SetMachine_Yield(timeQuantum.StartTime.AddMinutes(-60), item.MES_Customer_Name, item.MES_Station_Name, 3, item.Machine_Station_UID);
                    }
                    else //if (item.EndTime <= timeQuantum.StartTime.AddMinutes(-90))
                    {
                        //120分钟调用4次
                        SetMachine_Yield(timeQuantum.StartTime.AddMinutes(-90), item.MES_Customer_Name, item.MES_Station_Name, 4, item.Machine_Station_UID);
                    }
                }
                //获取所有已经同步的过得站点ID。
                List <int> yesMachine_Station_UIDs = machine_Schedule_ConfigDTOs.Select(o => o.Machine_Station_UID).ToList();
                //获取所有没有同步过得站点
                var nmachine_Schedule_ConfigDTOs = nomachine_Schedule_ConfigDTOs.Where(o => yesMachine_Station_UIDs.Contains(o.Machine_Station_UID) == false).ToList();
                foreach (var item in nmachine_Schedule_ConfigDTOs)
                {
                    SetMachine_Yield(timeQuantum.StartTime, item.MES_Customer_Name, item.MES_Station_Name, 1, item.Machine_Station_UID);
                }
            }
            else
            {
                //从来没有排程的时候执行下面的排程
                machine_Schedule_ConfigDTOs = nomachine_Schedule_ConfigDTOs;
                foreach (var item in machine_Schedule_ConfigDTOs)
                {
                    SetMachine_Yield(timeQuantum.StartTime, item.MES_Customer_Name, item.MES_Station_Name, 1, item.Machine_Station_UID);
                }
            }
        }