Browse Source

202503071123

baowei 6 days ago
parent
commit
22e7c00c4c

+ 2 - 41
ProductionLineMonitor.Application/Services/ExcelService.cs

@@ -116,7 +116,7 @@ namespace ProductionLineMonitor.Application.Services
                             x.MachineId == machine.Id &&
                             x.DataTime >= startTime &&
                             x.DataTime < endTime).OrderBy(o => o.DataTime).ToList();
-
+                        var OEEExtendFlag = new[] { false, false, false, false, false };
                         FileInfo file = new FileInfo(path);
 
                         //ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
@@ -479,46 +479,6 @@ namespace ProductionLineMonitor.Application.Services
                             }
                         }
 
-                        //var faultFrequencys = _faultService.GetFaultFrequencyTop10ByShift(
-                        //    machine.Id, dataStartTime, endTime, "安全门,门禁,提示上料,提示卸料,门锁");
-
-                        //var tables = new FaultFrequencyByShiftTable(faultFrequencys);
-
-                        //ExcelWorksheet worksheet1 = package.Workbook.Worksheets.Add($"{line.Name} {machine.Name} 报警");
-                        //worksheet1.View.ZoomScale = 80;
-                        //worksheet1.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
-
-                        //worksheet1.Column(1).Width = 5;
-                        //worksheet1.Column(2).Width = 10;
-                        //worksheet1.Column(3).Width = 30;
-
-                        //worksheet1.Cells[1, 1].Value = "NO";
-                        //worksheet1.Cells[1, 2].Value = "Code";
-                        //worksheet1.Cells[1, 3].Value = "Name";
-
-                        //for (int i = 0; i < tables.Shifts.Count(); i++)
-                        //{
-                        //    worksheet1.Column(i + 4).Width = 20;
-                        //    worksheet1.Cells[1, i + 4].Value = tables.Shifts[i];
-                        //}
-
-                        //for (int i = 0; i < tables.Nos.Count; i++)
-                        //{
-                        //    worksheet1.Cells[i + 2, 1].Value = tables.Nos[i];
-                        //    worksheet1.Cells[i + 2, 2].Value = tables.FaultCodes[i];
-                        //    worksheet1.Cells[i + 2, 3].Value = tables.FaultInfos[i];
-                        //    for (int j = 0; j < tables.Shifts.Count(); j++)
-                        //    {
-                        //        worksheet1.Cells[i + 2, j + 4].Value = tables.Counts[j, i];
-                        //    }
-                        //}
-
-                        //var databar = worksheet1.Cells["D2:Q33"].ConditionalFormatting.AddDatabar(Color.Red);
-
-                        //// 创建数据条条件格式对象
-                        //ExcelConditionalFormattingDataBar dataBarConditionalFormatting = (ExcelConditionalFormattingDataBar)worksheet.Cells["D2:Q33"].ConditionalFormatting;
-                        //// 设置渐变填充
-                        //dataBarConditionalFormatting.BarFill.Type = ExcelFillStyle.DarkGray;
 
                         ExcelChartSerie chartSerie;
                         ExcelChart chart = worksheet.Drawings.AddChart("chart", eChartType.ColumnStacked);
@@ -577,6 +537,7 @@ namespace ProductionLineMonitor.Application.Services
 
                         package.Save();
                     }
+
                     if ((bool)UtilizationRateEmail["DataSummary"]["IsAble"])
                     {
                         FileInfo file = new FileInfo(path);

+ 12 - 2
ProductionLineMonitor.Application/Services/OEEService/Dtos/MachineOEEInfoByPeriod.cs

@@ -41,7 +41,11 @@ namespace ProductionLineMonitor.Application.Services.OEEService.Dtos
         public int TotalTime { get; private set; }
         public int LoadMATTime { get; private set; }
         public int ReservedOne { get; private set; }
+        public int ReservedTwo { get; private set; }
         public int ReservedThree { get; private set; }
+        public int LoadMATSum { get; private set; }
+        public int AlarmSum { get; private set; }
+        public int ReservedTwoSum { get; private set; }
         public double IdelTimeRate
         {
             get
@@ -105,12 +109,12 @@ namespace ProductionLineMonitor.Application.Services.OEEService.Dtos
                 {
                     return 0;
                 }
-                return Math.Round(ReservedThree * 1.0 / TotalTime * 100, 1);
+                return Math.Round(ReservedThree * 1.0 / TotalTime * 100, 2);
             }
         }
         public void CalculateOEE(int i, int daysnum)
         {
-            if (i == 1)
+            if (i == 0 || i == 1)
             {
                 TotalTime = OutPutPerHours.Count() * 60 * 60;
             }
@@ -123,7 +127,13 @@ namespace ProductionLineMonitor.Application.Services.OEEService.Dtos
             IdelTime = OutPutPerHours.Sum(s => s.IdleTime.Value);
             DownTime = OutPutPerHours.Sum(s => s.AlarmTime.Value);
             LoadMATTime = OutPutPerHours.Sum(s => s.LoadMATTime.Value);
+            ReservedOne = OutPutPerHours.Sum(s => s.ReservedOne.Value);
+            ReservedThree = OutPutPerHours.Sum(s => s.ReservedThree.Value);
+            AlarmSum = OutPutPerHours.Sum(s => s.AlarmSum.Value);
+            LoadMATSum = OutPutPerHours.Sum(s => s.LoadMATSum.Value);
+            ReservedTwoSum = OutPutPerHours.Sum(s => s.ReservedTwo.Value);
         }
+
     }
 
     public class MachineOEEByPeroid

+ 6 - 1
ProductionLineMonitor.Application/Services/OEEService/IOEEService.cs

@@ -9,6 +9,11 @@ namespace ProductionLineMonitor.Application.Services.OEEService
     {
         List<MachineOEEInfo> GetOEE(string machineId, string startDate, string endDate);
 
-        Dictionary<string, List<MachineOEEInfoByPeriod>> GetOEEByPeriod(string machineIds, string startDate, string endDate, int peroid);
+        Dictionary<string, List<MachineOEEInfoByPeriod>> GetOEEByPeriod(string machineIds, DateTime startDate, DateTime endDate, int peroid, int dayORnight);
+
+        Dictionary<string, List<MachineOEEInfoByPeriod>> GetOEEByPeriodV1(string machineIds, string startDate, string endDate, int peroid);
+
+        List<MachineOEEInfoByPeriod> GetOEEByPeriodV2(string machineIds, string startDate, string endDate, int peroid, int shift);
+
     }
 }

+ 250 - 5
ProductionLineMonitor.Application/Services/OEEService/OEEService.cs

@@ -61,9 +61,241 @@ namespace ProductionLineMonitor.Application.Services.OEEService
         /// <param name="machineId"></param>
         /// <param name="startDate"></param>
         /// <param name="endDate"></param>
+        /// <param name="period">0:班,1:天,2:周,3:月</param>
+        /// <param name="dayORnight">period为0时有效,0:全部,1:白班,2:夜班</param>
+        /// <returns></returns>
+        public Dictionary<string, List<MachineOEEInfoByPeriod>> GetOEEByPeriod(string machineIdstr, DateTime startDate, DateTime endDate, int peroid, int dayORnight)
+        {
+            Dictionary<string, List<MachineOEEInfoByPeriod>> OEES_Dic = new Dictionary<string, List<MachineOEEInfoByPeriod>>();
+            List<string> machineids = new List<string>(machineIdstr.Split(","));
+            DateTime startTime = new DateTime();
+            DateTime endTime = new DateTime();
+            if (peroid == 0)
+            {
+                startTime = DateTime.Parse($"{startDate.ToString("yyyy-MM-dd")} 08:00:00");
+                endTime = DateTime.Parse($"{endDate.ToString("yyyy-MM-dd")} 08:00:00").AddDays(1);
+                List<MachineOutPutPerHour> outputs = _unitOfWork.MachineOutPutPerHourRepository
+                .GetList(
+                    x =>
+                    machineids.Contains(x.MachineId) &&
+                    x.DataTime >= startTime &&
+                    x.DataTime < endTime)
+                .OrderBy(
+                    o => o.DataTime)
+                .ToList();
+                if (dayORnight == 1)
+                {
+                    endTime = endTime.AddHours(-12);
+                }
+                else if (dayORnight == 2)
+                {
+                    startTime = startTime.AddHours(12);
+                }
+                foreach (var item in machineids)
+                {
+                    List<MachineOEEInfoByPeriod> OEES = new List<MachineOEEInfoByPeriod>();
+                    for (var i = startTime; i < endTime; i = i.AddHours(12))
+                    {
+                        DateTime tempTime = i.AddHours(12);
+                        MachineOEEInfoByPeriod machineOEE = new MachineOEEInfoByPeriod
+                        {
+                            StartTime = i,
+                            EndTime = tempTime,
+                            OutPutPerHours = outputs.FindAll(x => x.DataTime >= i && x.DataTime < tempTime && x.MachineId == item)
+                        };
+                        machineOEE.CalculateOEE(peroid, 0);
+                        OEES.Add(machineOEE);
+                    }
+                    OEES_Dic.Add(item, OEES);
+                }
+                return OEES_Dic;
+            }
+            if (peroid == 1)
+            {
+                startTime = DateTime.Parse($"{startDate.ToString("yyyy-MM-dd")} 08:00:00");
+                endTime = DateTime.Parse($"{endDate.ToString("yyyy-MM-dd")} 08:00:00").AddDays(1);
+                List<MachineOutPutPerHour> outputs = _unitOfWork.MachineOutPutPerHourRepository
+                .GetList(
+                    x =>
+                    machineids.Contains(x.MachineId) &&
+                    x.DataTime >= startTime &&
+                    x.DataTime < endTime)
+                .OrderBy(
+                    o => o.DataTime)
+                .ToList();
+                foreach (var item in machineids)
+                {
+                    List<MachineOEEInfoByPeriod> OEES = new List<MachineOEEInfoByPeriod>();
+                    for (var i = startTime; i < endTime; i = i.AddHours(24))
+                    {
+                        DateTime tempTime = i.AddHours(24);
+                        MachineOEEInfoByPeriod machineOEE = new MachineOEEInfoByPeriod
+                        {
+                            StartTime = i,
+                            EndTime = tempTime,
+                            OutPutPerHours = outputs.FindAll(x => x.DataTime >= i && x.DataTime < tempTime && x.MachineId == item)
+                        };
+                        machineOEE.CalculateOEE(peroid, 1);
+                        OEES.Add(machineOEE);
+                    }
+                    OEES_Dic.Add(item, OEES);
+                }
+                return OEES_Dic;
+            }
+            else if (peroid == 2)
+            {
+                startTime = DateTime.Parse($"{startDate.ToString("yyyy-MM-dd")} 08:00:00");
+                endTime = DateTime.Parse($"{endDate.ToString("yyyy-MM-dd")} 08:00:00");
+                int week1 = (int)startTime.DayOfWeek;
+                int week2 = (int)endTime.DayOfWeek;
+                startTime = startTime.AddDays(week1 == 0 ? -6 : 1 - week1);
+                endTime = endTime.AddDays(week2 == 0 ? 1 : 8 - week2);
+                List<MachineOutPutPerHour> outputs = _unitOfWork.MachineOutPutPerHourRepository
+                .GetList(
+                    x =>
+                    machineids.Contains(x.MachineId) &&
+                    x.DataTime >= startTime &&
+                    x.DataTime < endTime)
+                .OrderBy(
+                    o =>
+                    o.DataTime)
+                .ToList();
+
+                foreach (var item in machineids)
+                {
+                    List<MachineOEEInfoByPeriod> OEES = new List<MachineOEEInfoByPeriod>();
+                    for (var i = startTime; i < endTime; i = i.AddDays(7))
+                    {
+                        DateTime tempTime1 = i.AddDays(7);
+                        var outputhourslist = new List<MachineOutPutPerHour>();
+                        for (var j = i; j < tempTime1; j = j.AddDays(1))
+                        {
+                            DateTime tempTime2 = j.AddDays(1);
+                            var outputperhours = outputs.FindAll(x => x.DataTime >= j && x.DataTime < tempTime2 && x.MachineId == item);
+                            if (outputperhours != null && outputperhours.Count != 0)
+                            {
+                                MachineOutPutPerHour machineoutputhour = new MachineOutPutPerHour()
+                                {
+                                    MachineId = outputperhours[0].MachineId,
+                                    ModuleType = outputperhours[0].ModuleType,
+                                    DataTime = outputperhours[0].DataTime,
+                                    AutoRunTime = outputperhours.Sum(s => s.AutoRunTime.Value),
+                                    AlarmTime = outputperhours.Sum(s => s.AlarmTime.Value),
+                                    IdleTime = outputperhours.Sum(s => s.IdleTime.Value),
+                                    IdleTimeUpstream = outputperhours.Sum(s => s.IdleTimeUpstream.Value),
+                                    IdleTimeDownstream = outputperhours.Sum(s => s.IdleTimeDownstream.Value),
+                                    IdleTimeSelf = outputperhours.Sum(s => s.IdleTimeSelf.Value),
+                                    OutPut = outputperhours.Sum(s => s.OutPut.Value),
+                                    ActualTT = outputperhours.Sum(s => s.ActualTT.Value),
+                                    AlarmSum = outputperhours.Sum(s => s.AlarmSum.Value),
+                                    LoadMATSum = outputperhours.Sum(s => s.LoadMATSum.Value),
+                                    LoadMATTime = outputperhours.Sum(s => s.LoadMATTime.Value),
+                                    ReservedOne = outputperhours.Sum(s => s.ReservedOne.Value),
+                                    ReservedTwo = outputperhours.Sum(s => s.ReservedTwo.Value),
+                                    ReservedThree = outputperhours.Sum(s => s.ReservedThree.Value),
+                                    CreateTime = outputperhours[0].CreateTime,
+                                    UpdateTime = outputperhours[0].UpdateTime
+                                };
+                                outputhourslist.Add(machineoutputhour);
+                            }
+                        }
+
+                        MachineOEEInfoByPeriod machineOEE = new MachineOEEInfoByPeriod
+                        {
+                            StartTime = i,
+                            EndTime = tempTime1,
+                            OutPutPerHours = outputhourslist
+                        };
+                        machineOEE.CalculateOEE(peroid, 7);
+                        OEES.Add(machineOEE);
+                    }
+                    OEES_Dic.Add(item, OEES);
+                }
+
+                return OEES_Dic;
+            }
+            else
+            {
+                startTime = DateTime.Parse($"{startDate.ToString("yyyy-MM")}-01 08:00:00");
+                endTime = DateTime.Parse($"{endDate.ToString("yyyy-MM")}-01 08:00:00").AddMonths(1);
+
+                List<MachineOutPutPerHour> outputs = _unitOfWork.MachineOutPutPerHourRepository
+                .GetList(
+                    x =>
+                    machineids.Contains(x.MachineId) &&
+                    x.DataTime >= startTime &&
+                    x.DataTime < endTime)
+                .OrderBy(
+                    o =>
+                    o.DataTime)
+                .ToList();
+
+                foreach (var item in machineids)
+                {
+                    List<MachineOEEInfoByPeriod> OEES = new List<MachineOEEInfoByPeriod>();
+                    for (var i = startTime; i < endTime; i = i.AddMonths(1))
+                    {
+                        DateTime tempTime1 = i.AddMonths(1);
+                        var outputhourslist = new List<MachineOutPutPerHour>();
+                        for (var j = i; j < tempTime1; j = j.AddDays(1))
+                        {
+                            DateTime tempTime2 = j.AddDays(1);
+                            var outputperhours = outputs.FindAll(x => x.DataTime >= j && x.DataTime < tempTime2 && x.MachineId == item);
+                            if ((outputperhours != null && outputperhours.Count != 0))
+                            {
+                                MachineOutPutPerHour machineoutputhour = new MachineOutPutPerHour()
+                                {
+                                    MachineId = outputperhours[0].MachineId,
+                                    ModuleType = outputperhours[0].ModuleType,
+                                    DataTime = outputperhours[0].DataTime,
+                                    AutoRunTime = outputperhours.Sum(s => s.AutoRunTime.Value),
+                                    AlarmTime = outputperhours.Sum(s => s.AlarmTime.Value),
+                                    IdleTime = outputperhours.Sum(s => s.IdleTime.Value),
+                                    IdleTimeUpstream = outputperhours.Sum(s => s.IdleTimeUpstream.Value),
+                                    IdleTimeDownstream = outputperhours.Sum(s => s.IdleTimeDownstream.Value),
+                                    IdleTimeSelf = outputperhours.Sum(s => s.IdleTimeSelf.Value),
+                                    OutPut = outputperhours.Sum(s => s.OutPut.Value),
+                                    ActualTT = outputperhours.Sum(s => s.ActualTT.Value),
+                                    AlarmSum = outputperhours.Sum(s => s.AlarmSum.Value),
+                                    LoadMATSum = outputperhours.Sum(s => s.LoadMATSum.Value),
+                                    LoadMATTime = outputperhours.Sum(s => s.LoadMATTime.Value),
+                                    ReservedOne = outputperhours.Sum(s => s.ReservedOne.Value),
+                                    ReservedTwo = outputperhours.Sum(s => s.ReservedTwo.Value),
+                                    ReservedThree = outputperhours.Sum(s => s.ReservedThree.Value),
+                                    CreateTime = outputperhours[0].CreateTime,
+                                    UpdateTime = outputperhours[0].UpdateTime
+                                };
+                                outputhourslist.Add(machineoutputhour);
+                            }
+                        }
+
+                        MachineOEEInfoByPeriod machineOEE = new MachineOEEInfoByPeriod
+                        {
+                            StartTime = i,
+                            EndTime = tempTime1,
+                            OutPutPerHours = outputhourslist
+                        };
+                        machineOEE.CalculateOEE(peroid, DateTime.DaysInMonth(i.Year, i.Month));
+                        OEES.Add(machineOEE);
+                    }
+                    OEES_Dic.Add(item, OEES);
+                }
+
+                return OEES_Dic;
+            }
+
+
+        }
+
+        /// <summary>
+        /// 屏蔽2月10日之前的数据
+        /// </summary>
+        /// <param name="machineId"></param>
+        /// <param name="startDate"></param>
+        /// <param name="endDate"></param>
         /// <param name="period">1:天,2:周,3:月</param>
         /// <returns></returns>
-        public Dictionary<string, List<MachineOEEInfoByPeriod>> GetOEEByPeriod(string machineIdstr, string startDate, string endDate, int peroid)
+        public Dictionary<string, List<MachineOEEInfoByPeriod>> GetOEEByPeriodV1(string machineIdstr, string startDate, string endDate, int peroid)
         {
             Dictionary<string, List<MachineOEEInfoByPeriod>> OEES_Dic = new Dictionary<string, List<MachineOEEInfoByPeriod>>();
             List<string> machineids = new List<string>(machineIdstr.Split(","));
@@ -130,7 +362,7 @@ namespace ProductionLineMonitor.Application.Services.OEEService
                         for (var j = i; j < tempTime1; j = j.AddDays(1))
                         {
                             DateTime tempTime2 = j.AddDays(1);
-                            var outputperhours =  outputs.FindAll(x => x.DataTime >= j && x.DataTime < tempTime2 && x.MachineId == item);
+                            var outputperhours = outputs.FindAll(x => x.DataTime >= j && x.DataTime < tempTime2 && x.MachineId == item);
                             if (outputperhours != null && outputperhours.Count != 0)
                             {
                                 MachineOutPutPerHour machineoutputhour = new MachineOutPutPerHour()
@@ -174,12 +406,20 @@ namespace ProductionLineMonitor.Application.Services.OEEService
             {
                 startTime = DateTime.Parse($"{startDate}-01 08:00:00");
                 endTime = DateTime.Parse($"{endDate}-01 08:00:00").AddMonths(1);
-
+                DateTime startTime_temp = new DateTime();
+                if (startDate == "2025-02")
+                {
+                    startTime_temp = DateTime.Parse($"{startDate}-10 08:00:00");
+                }
+                else
+                {
+                    startTime_temp = DateTime.Parse($"{startDate}-01 08:00:00");
+                }
                 List<MachineOutPutPerHour> outputs = _unitOfWork.MachineOutPutPerHourRepository
                 .GetList(
                     x =>
                     machineids.Contains(x.MachineId) &&
-                    x.DataTime >= startTime &&
+                    x.DataTime >= startTime_temp &&
                     x.DataTime < endTime)
                 .OrderBy(
                     o =>
@@ -218,7 +458,7 @@ namespace ProductionLineMonitor.Application.Services.OEEService
                                     CreateTime = outputperhours[0].CreateTime,
                                     UpdateTime = outputperhours[0].UpdateTime
                                 };
-                                outputhourslist.Add(machineoutputhour); 
+                                outputhourslist.Add(machineoutputhour);
                             }
                         }
 
@@ -239,5 +479,10 @@ namespace ProductionLineMonitor.Application.Services.OEEService
 
 
         }
+
+        public List<MachineOEEInfoByPeriod> GetOEEByPeriodV2(string machineIds, string startDate, string endDate, int peroid, int shift)
+        {
+            throw new NotImplementedException();
+        }
     }
 }

+ 4 - 0
ProductionLineMonitor.Core/Models/Machine.cs

@@ -43,5 +43,9 @@ namespace ProductionLineMonitor.Core.Models
         /// OEE配置项
         /// </summary>
         public string OEEExtendSettings { get; set; }
+        /// <summary>
+        /// 是否展示
+        /// </summary>
+        public int? IsShow { get; set; }
     }
 }

+ 6 - 0
ProductionLineMonitor.Core/Models/ProductionLine.cs

@@ -50,5 +50,11 @@ namespace ProductionLineMonitor.Core.Models
         /// 厂号
         /// </summary>
         public string FactoryNo { get; set; }
+
+        /// <summary>
+        /// 代表设备ID
+        /// </summary>
+        public string RepresentativeDeviceId { get; set; }
+
     }
 }

+ 6 - 0
ProductionLineMonitor.Core/Services/ProductionLine/IProductionLineCoreService.cs

@@ -18,6 +18,12 @@ namespace ProductionLineMonitor.Core.Services
         /// <returns></returns>
         TreeDto GetProductionLineMachineTree();
 
+        /// <summary>
+        /// 获取产线机台目录树(带汇总)
+        /// </summary>
+        /// <returns></returns>
+        TreeDto GetProductionLineMachineTreeV1();
+
         /// <summary>
         /// 获取产线目录树
         /// </summary>

+ 40 - 20
ProductionLineMonitor.Core/Services/ProductionLine/ProductionLineCoreService.cs

@@ -162,32 +162,55 @@ namespace ProductionLineMonitor.Core.Services
                    .GetList(x => x.ProductionLineId == production.Id)
                    .OrderBy(o => o.ProductionLineOrder).ToList();
 
-                if (production.Name != "Y5 Chamber")
+                foreach (var machine in machines)
                 {
-                    foreach (var machine in machines)
+                    node.Children.Add(new Node()
                     {
-                        node.Children.Add(new Node()
-                        {
-                            Id = machine.Id.ToString(),
-                            Name = machine.Name,
-                            Children = null
-                        });
-                    }
+                        Id = machine.Id.ToString(),
+                        Name = machine.Name,
+                        Children = null
+                    });
                 }
-                else
+
+                nodes.Add(node);
+            }
+            tree.Nodes = nodes;
+            return tree;
+        }
+
+        public TreeDto GetProductionLineMachineTreeV1()
+        {
+            TreeDto tree = new TreeDto();
+            List<ProductionLine> productionlines = _unitOfWork.ProductionLineRepository
+                .GetList().OrderBy(o => o.Order).ToList();
+            List<Node> nodes = new List<Node>();
+            foreach (var productionline in productionlines)
+            {
+                Node node = new Node
+                {
+                    Id = productionline.Id.ToString(),
+                    Name = productionline.Name,
+                    Open = true,
+                    Children = new List<Node>()
+                };
+
+                List<Machine> machines = _unitOfWork.MachineRepository
+                   .GetList(x => x.ProductionLineId == productionline.Id)
+                   .OrderBy(o => o.ProductionLineOrder).ToList();
+
+                if (!string.IsNullOrEmpty(productionline.RepresentativeDeviceId) && machines != null && machines.Count != 0)
                 {
                     node.Children.Add(new Node()
                     {
-                        Id = "ChamberTotal",
-                        Name = "Chamber汇总",
+                        Id = productionline.RepresentativeDeviceId,
+                        Name = "汇总",
                         Children = null
                     });
-
-                    List<string> chamberids = new List<string>();
-
-                    foreach (var machine in machines)
+                }
+                foreach (var machine in machines)
+                {
+                    if (machine.IsShow != 0)
                     {
-                        chamberids.Add(machine.Id.ToString());
                         node.Children.Add(new Node()
                         {
                             Id = machine.Id.ToString(),
@@ -195,10 +218,7 @@ namespace ProductionLineMonitor.Core.Services
                             Children = null
                         });
                     }
-                    node.Children[0].Id = String.Join(",", chamberids);
                 }
-
-
                 nodes.Add(node);
             }
             tree.Nodes = nodes;

+ 34 - 31
ProductionLineMonitor.Web/Controllers/EYZManufacturingPlatformController.cs

@@ -17,16 +17,19 @@ namespace ProductionLineMonitor.Web.Controllers
         private readonly IReportFormService _reportFormService;
         private readonly IOEEService _oeeService;
         private readonly IExcelService _excelService;
+        private readonly IProductionLineCoreService _productionLineService;
         private readonly IUnitOfWork _unitOfWork;
         public EYZManufacturingPlatformController(
             IReportFormService reportFormService,
             IOEEService oeeService,
             IExcelService excelService,
+            IProductionLineCoreService productionLineService,
             IUnitOfWork unitOfWork)
         {
             _reportFormService = reportFormService;
             _oeeService = oeeService;
             _excelService = excelService;
+            _productionLineService = productionLineService;
             _unitOfWork = unitOfWork;
         }
 
@@ -36,46 +39,46 @@ namespace ProductionLineMonitor.Web.Controllers
             return View();
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <param name="peroid"></param>//0:按班;1:天;2:周;3:月
+        /// <param name="dayOrnight"></param>//peroid为0时有效,0:汇总,1:白班数据,2:夜班数据
+        /// <returns></returns>
         [HttpPost]
-        public IActionResult GetMachineStatisticV2(string id, DateTime startTime, DateTime endTime, int peroid)
+        public IActionResult GetMachineStatisticV4(string id, DateTime startTime, DateTime endTime, int peroid, int dayOrnight)
         {
-            //MachineOEE machine = new MachineOEE();
-            Dictionary<string, List<MachineOEEInfoByPeriod>> lst = new Dictionary<string, List<MachineOEEInfoByPeriod>>();
-            if (peroid == 3)
-            {
-                lst = _oeeService.GetOEEByPeriod(id,
-                startTime.ToString("yyyy-MM"), endTime.ToString("yyyy-MM"), peroid);
-            }
-            else
-            {
-                lst = _oeeService.GetOEEByPeriod(id,
-                startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"), peroid);
-            }
-
-            return Ok(ResultDto<Dictionary<string, List<MachineOEEInfoByPeriod>>>.Success(lst));
+            var list = _oeeService.GetOEEByPeriod(id, startTime, endTime, peroid, dayOrnight);
+            return Ok(ResultDto<Dictionary<string, List<MachineOEEInfoByPeriod>>>.Success(list));
         }
 
         [HttpPost]
-        public IActionResult GetMachineStatisticV1(string id, DateTime startTime, DateTime endTime)
+        public IActionResult GetOEEExtendSetting(string ids)
         {
-            //MachineOEE machine = new MachineOEE();
-            List<MachineOEEInfo> lst = _oeeService.GetOEE(id,
-                startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
-            return Ok(ResultDto<List<MachineOEEInfo>>.Success(lst));
+            var idList = ids.Split(',');
+            var machine = _unitOfWork.Repository<Machine>().GetList().Where(x => idList.Contains(x.Id));
+            Dictionary<string, string> DicOEEExtend = new Dictionary<string, string>();
+            if (machine != null && machine.Count() != 0)
+            {
+                foreach (var item in machine)
+                {
+                    DicOEEExtend.Add(item.Id, string.IsNullOrEmpty(item.OEEExtendSettings) ? "" : item.OEEExtendSettings);
+                }
+            }
+            return Ok(ResultDto<Dictionary<string, string>>.Success(DicOEEExtend));
         }
 
-        [HttpPost]
-        public IActionResult GetOEEExtendSetting(string id)
+        /// <summary>
+        ///带汇总
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        public IActionResult GetProductionLineMachineTreeV1()
         {
-            var machine = _unitOfWork.Repository<Machine>().GetList().Where(x => x.Id == id);
-            if (machine != null && machine.Count() != 0 && !String.IsNullOrEmpty(machine.First().OEEExtendSettings))
-            {
-                return Ok(ResultDto<string>.Success(machine.First().OEEExtendSettings));
-            }
-            else
-            {
-                return Ok(ResultDto<string>.Success(""));
-            }
+            return Ok(_productionLineService.GetProductionLineMachineTreeV1().Nodes);
         }
     }
 }

+ 10 - 0
ProductionLineMonitor.Web/Controllers/ProductionLineController.cs

@@ -42,6 +42,16 @@ namespace ProductionLineMonitor.Web.Controllers
             return Ok(_productionLineService.GetProductionLineMachineTree().Nodes);
         }
 
+        /// <summary>
+        ///带汇总
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        public IActionResult GetProductionLineMachineTreeV1()
+        {
+            return Ok(_productionLineService.GetProductionLineMachineTreeV1().Nodes);
+        }
+
         [HttpPost]
         public IActionResult GetMachineDayData([FromBody]ReadDayDto dto)
         {

+ 51 - 16
ProductionLineMonitor.Web/Controllers/ReportFormController.cs

@@ -73,37 +73,72 @@ namespace ProductionLineMonitor.Web.Controllers
             return Ok(ResultDto<List<MachineOEEInfo>>.Success(lst));
         }
 
+        //[HttpPost]
+        //public IActionResult GetMachineStatisticV2(string id, DateTime startTime, DateTime endTime, int peroid)
+        //{
+        //    //MachineOEE machine = new MachineOEE();
+        //    Dictionary<string, List<MachineOEEInfoByPeriod>> lst = new Dictionary<string, List<MachineOEEInfoByPeriod>>();
+        //    if (peroid == 3)
+        //    {
+        //        lst = _oeeService.GetOEEByPeriod(id,
+        //        startTime.ToString("yyyy-MM"), endTime.ToString("yyyy-MM"), peroid,0);
+        //    }
+        //    else
+        //    {
+        //        lst = _oeeService.GetOEEByPeriod(id,
+        //        startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"), peroid, 0);
+        //    }
+
+        //    return Ok(ResultDto<Dictionary<string, List<MachineOEEInfoByPeriod>>>.Success(lst));
+        //}
+
         [HttpPost]
-        public IActionResult GetMachineStatisticV2(string id, DateTime startTime, DateTime endTime, int peroid)
+        public IActionResult GetMachineStatisticV3(string id, DateTime startTime, DateTime endTime, int peroid, int shift)
         {
-            //MachineOEE machine = new MachineOEE();
-            Dictionary<string, List<MachineOEEInfoByPeriod>> lst = new Dictionary<string, List<MachineOEEInfoByPeriod>>();
+            List<MachineOEEInfoByPeriod> lst = new List<MachineOEEInfoByPeriod>();
             if (peroid == 3)
             {
-                lst = _oeeService.GetOEEByPeriod(id,
-                startTime.ToString("yyyy-MM"), endTime.ToString("yyyy-MM"), peroid);
+                lst = _oeeService.GetOEEByPeriodV2(id,
+                startTime.ToString("yyyy-MM"), endTime.ToString("yyyy-MM"), peroid, shift);
             }
             else
             {
-                lst = _oeeService.GetOEEByPeriod(id,
-                startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"), peroid);
+                lst = _oeeService.GetOEEByPeriodV2(id,
+                startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"), peroid, shift);
             }
+            return Ok(ResultDto<List<MachineOEEInfoByPeriod>>.Success(lst));
+        }
 
-            return Ok(ResultDto<Dictionary<string, List<MachineOEEInfoByPeriod>>>.Success(lst));
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <param name="peroid"></param>//0:按班;1:天;2:周;3:月
+        /// <param name="dayOrnight"></param>//peroid为0时有效,0:汇总,1:白班数据,2:夜班数据
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult GetMachineStatisticV4(string id, DateTime startTime, DateTime endTime, int peroid, int dayOrnight)
+        {
+            var list = _oeeService.GetOEEByPeriod(id, startTime, endTime, peroid, dayOrnight);
+            return Ok(ResultDto<Dictionary<string, List<MachineOEEInfoByPeriod>>>.Success(list));
         }
 
         [HttpPost]
-        public IActionResult GetOEEExtendSetting(string id)
+        public IActionResult GetOEEExtendSetting(string ids)
         {
-            var machine = _unitOfWork.Repository<Machine>().GetList().Where(x => x.Id == id);
-            if (machine != null && machine.Count() != 0 && !String.IsNullOrEmpty(machine.First().OEEExtendSettings))
+            var idList = ids.Split(',');
+            var machine = _unitOfWork.Repository<Machine>().GetList().Where(x => idList.Contains(x.Id));
+            Dictionary<string, string> DicOEEExtend = new Dictionary<string, string>();
+            if (machine != null && machine.Count() != 0)
             {
-                return Ok(ResultDto<string>.Success(machine.First().OEEExtendSettings));
-            }
-            else
-            {
-                return Ok(ResultDto<string>.Success(""));
+                foreach (var item in machine)
+                {
+                    DicOEEExtend.Add(item.Id, string.IsNullOrEmpty(item.OEEExtendSettings) ? "" : item.OEEExtendSettings);
+                }
             }
+            return Ok(ResultDto<Dictionary<string, string>>.Success(DicOEEExtend));
         }
 
         private List<object[]> GetOee(string moduleType, IEnumerable<MachineStatistic> oees)

+ 29 - 21
ProductionLineMonitor.Web/Views/EYZManufacturingPlatform/Y5OEE.cshtml

@@ -37,41 +37,42 @@
                 border-left: 1px solid WhiteSmoke;
                 border-top: 1px solid WhiteSmoke;
             }
+
+        #main_body {
+            height: 100vh;
+        }
     </style>
 </head>
 @* skin-blue sidebar-mini sidebar-collapse
 hold-transition skin-blue sidebar-mini *@
 <body id="main_body" class="skin-blue sidebar-mini sidebar-collapse">
     <div class="wrapper">
-        <div class="content">
-
+        <div class="content" style="height:100vh">
             <div id="app" class="col-md-12">
                 <div class="box box-primary">
                     <div class="box-body">
                         <div class="col-md-1">
-                            <div class="over">
+                            <div class="over" style="visibility: hidden">
                                 <ul id="productionLineTree" class="ztree"></ul>
                             </div>
                         </div>
-                        <div class="col-md-11">
+                        <div class="col-md-10">
                             <div id="form1" class="col-md-12">
                                 <div class="input-group input-daterange" style="width:400px;float:left;padding:0px">
                                     <div class="input-group-addon">起止日期</div>
-                                    <input id="date1" type="text" class="form-control date" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")">
+                                    <input id="date1" type="text" class="form-control date" value="@DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd")">
                                     <div class="input-group-addon">-</div>
                                     <input id="date2" type="text" class="form-control date" value="@DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")">
                                 </div>
-                                <div id="methodchoose" class="input-group input-daterange" style="width:200px;float:left;padding-left:15px">
+                                <div class="input-group input-daterange" style="width:200px;float:left;padding-left:15px">
                                     <div class="input-group-addon">By</div>
-                                    <select id="selectMonth" class="form-control" v-on:change="selected()">
+                                    <select id="selectPeroid" class="form-control" v-on:change="selected()">
+                                        <option value="0">Shift</option>
                                         <option value="1">Day</option>
                                         <option value="2">Week</option>
                                         <option value="3">Month</option>
                                     </select>
                                 </div>
-                                <div id="menuContent" style="position:absolute; display:none; z-index:10">
-                                    <ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 200px;"></ul>
-                                </div>
                                 <div class="col-md-1" style="padding-left:15px">
                                     <div class="btn-group">
                                         <button type="button" class="btn btn-block btn-default"
@@ -90,7 +91,6 @@ hold-transition skin-blue sidebar-mini *@
                                          style="height: 500px;">
                                     </div>
                                     <div id="container2"
-                                         class="col-md-6"
                                          style="height: 500px;">
                                     </div>
 
@@ -98,7 +98,7 @@ hold-transition skin-blue sidebar-mini *@
                                         <p class="text-center">
                                             {{ outputInfo }}
                                         </p>
-                                        <table id="data" height="500px" style="margin-left: 4px;margin:auto">
+                                        <table id="data" style="margin:auto;">
                                             <thead>
                                                 <tr>
                                                     <th style="width: 10%">时段</th>
@@ -106,17 +106,25 @@ hold-transition skin-blue sidebar-mini *@
                                                     <th style="width: 10%">运行时间</th>
                                                     <th style="width: 10%">报警时间</th>
                                                     <th style="width: 10%">待料时间</th>
+                                                    <th style="width: 10%">换料时间</th>
+                                                    <th style="width: 10%">产能</th>
+                                                    <th style="width: 10%">TT</th>
+                                                    <th style="width: 10%">报警次数</th>
                                                 </tr>
                                             </thead>
-                                            <tbody>
-                                                <tr v-for="(output, index) in outputs">
-                                                    <td>{{ output.period }}</td>
-                                                    <td>{{ output.moduleType }}</td>
-                                                    <td>{{ }}</td>
-                                                    <td>{{ }}</td>
-                                                    <td>{{ }}</td>
-                                                </tr>
-                                            </tbody>
+                                            @* <tbody>
+                                            <tr v-for="(output, index) in outputs">
+                                            <td>{{ output.period }}</td>
+                                            <td>{{ output.moduleType }}</td>
+                                            <td>{{ Math.round(output.autoRunTime/60*10)/10 }}</td>
+                                            <td>{{ Math.round(output.alarmTime/60*10)/10 }}</td>
+                                            <td>{{ Math.round(output.idleTime/60*10)/10 }}</td>
+                                            <td>{{ Math.round(output.loadMATTime/60*10)/10 }}</td>
+                                            <td>{{ output.outPut }}</td>
+                                            <td>{{ output.tt }}</td>
+                                            <td>{{ output.alarmSum }}</td>
+                                            </tr>
+                                            </tbody> *@
                                         </table>
                                     </div>
                                 </div>

+ 21 - 61
ProductionLineMonitor.Web/Views/ReportForm/Index.cshtml

@@ -39,25 +39,19 @@
                 <div id="form1" class="col-md-12">
                     <div class="input-group input-daterange" style="width:400px;float:left;padding:0px">
                         <div class="input-group-addon">起止日期</div>
-                        <input id="date1" type="text" class="form-control date" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")">
+                        <input id="date1" type="text" class="form-control date" value="@DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd")">
                         <div class="input-group-addon">-</div>
                         <input id="date2" type="text" class="form-control date" value="@DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")">
                     </div>
-                    <div id="devicechoose" class="input-group input-daterange" style="width:300px;float:left;padding-left:15px">
-                        <div  class="input-group-addon">设备选择</div>
-                        <input id="mutiSelect" class="form-control" v-on:click="showMenu()">
-                    </div>
-                    <div id="methodchoose" class="input-group input-daterange" style="width:200px;float:left;padding-left:15px">
+                    <div class="input-group input-daterange" style="width:200px;float:left;padding-left:15px">
                         <div class="input-group-addon">By</div>
-                        <select id="selectMonth" class="form-control" v-on:change="selected()">
+                        <select id="selectPeroid" class="form-control" v-on:change="selected()">
+                            <option value="0">Shift</option>
                             <option value="1">Day</option>
                             <option value="2">Week</option>
                             <option value="3">Month</option>
                         </select>
                     </div>
-                    <div id="menuContent" style="position:absolute; display:none; z-index:10">
-                        <ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 200px;"></ul>
-                    </div>
                     <div class="col-md-1" style="padding-left:15px">
                         <div class="btn-group">
                             <button type="button" class="btn btn-block btn-default"
@@ -76,15 +70,14 @@
                              style="height: 500px;">
                         </div>
                         <div id="container2"
-                             class="col-md-6"
-                            style="height: 500px;">
-                         </div>
+                             style="height: 500px;">
+                        </div>
 
                         <div id="tbdata" class="col-md-12" style="padding-top: 10px;">
                             <p class="text-center">
                                 {{ outputInfo }}
                             </p>
-                            <table id="data" height="500px" style="margin-left: 4px">
+                            <table id="data" style="margin:auto;">
                                 <thead>
                                     <tr>
                                         <th style="width: 10%">时段</th>
@@ -98,56 +91,23 @@
                                         <th style="width: 10%">报警次数</th>
                                     </tr>
                                 </thead>
-                                <tbody>
-                                    <tr v-for="(output, index) in outputs">
-                                        <td>{{ output.period }}</td>
-                                        <td>{{ output.moduleType }}</td>
-                                        <td>{{ Math.round(output.autoRunTime/60*10)/10 }}</td>
-                                        <td>{{ Math.round(output.alarmTime/60*10)/10 }}</td>
-                                        <td>{{ Math.round(output.idleTime/60*10)/10 }}</td>
-                                        <td>{{ Math.round(output.loadMATTime/60*10)/10 }}</td>
-                                        <td>{{ output.outPut }}</td>
-                                        <td>{{ output.tt }}</td>
-                                        <td>{{ output.alarmSum }}</td>
-                                    </tr>
-                                </tbody>
+                                 @* <tbody>
+                                     <tr v-for="(output, index) in outputs">
+                                         <td>{{ output.period }}</td>
+                                         <td>{{ output.moduleType }}</td>
+                                         <td>{{ Math.round(output.autoRunTime/60*10)/10 }}</td>
+                                         <td>{{ Math.round(output.alarmTime/60*10)/10 }}</td>
+                                         <td>{{ Math.round(output.idleTime/60*10)/10 }}</td>
+                                         <td>{{ Math.round(output.loadMATTime/60*10)/10 }}</td>
+                                         <td>{{ output.outPut }}</td>
+                                         <td>{{ output.tt }}</td>
+                                         <td>{{ output.alarmSum }}</td>
+                                     </tr>
+                                 </tbody> *@
                             </table>
                         </div>
                     </div>
                 </div>
-                @* <div class="col-md-6" style="padding-top: 10px;">
-                    <p class="text-center">
-                        日期:{{ outputInfo }}
-                    </p>
-                    <table id="data" height="300px" style="margin-left: 4px">
-                        <thead>
-                            <tr>
-                                <th style="width: 10%">时段</th>
-                                <th style="width: 10%">机种</th>
-                                <th style="width: 10%">运行时间</th>
-                                <th style="width: 10%">报警时间</th>
-                                <th style="width: 10%">待料时间</th>
-                                <th style="width: 10%">换料时间</th>
-                                <th style="width: 10%">产能</th>
-                                <th style="width: 10%">TT</th>
-                                <th style="width: 10%">报警次数</th>
-                            </tr>
-                        </thead>
-                        <tbody>
-                            <tr v-for="(output, index) in outputs">
-                                <td>{{ output.period }}</td>
-                                <td>{{ output.moduleType }}</td>
-                                <td>{{ Math.round(output.autoRunTime/60*10)/10 }}</td>
-                                <td>{{ Math.round(output.alarmTime/60*10)/10 }}</td>
-                                <td>{{ Math.round(output.idleTime/60*10)/10 }}</td>
-                                <td>{{ Math.round(output.loadMATTime/60*10)/10 }}</td>
-                                <td>{{ output.outPut }}</td>
-                                <td>{{ output.tt }}</td>
-                                <td>{{ output.alarmSum }}</td>
-                            </tr>
-                        </tbody>
-                    </table>
-                 </div> *@
             </div>
         </div>
     </div>
@@ -159,7 +119,7 @@
     <script src="~/lib/adminlte/bower/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
     <script src="~/lib/adminlte/bower/bootstrap-datepicker/js/locales/bootstrap-datepicker.zh-cn.js"></script>
     <script src="~/lib/echarts/echarts.min.js"></script>
-    <script src="~/js/report-form/report-form-v1.js"></script>
+    <script src="~/js/report-form/report-form-v2.js"></script>
     <script src="~/lib/ztree.v3/js/jquery.ztree.excheck.min.js"></script>
     <script src="~/lib/moment.js/moment-with-locales.min.js"></script>
 }

File diff suppressed because it is too large
+ 527 - 696
ProductionLineMonitor.Web/wwwroot/js/EYZ-manufacturing-platform/EYZ-manufacturing-platform.js


+ 179 - 123
ProductionLineMonitor.Web/wwwroot/js/report-form/report-form-v1.js

@@ -88,7 +88,7 @@
                             title: 'save excel',
                             icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
                             onclick: () => {
-                                this.exportExcelTemplate();
+                                this.exportExcelTemplate(1);
                             }
                         }
                     },
@@ -142,74 +142,13 @@
                     }
                 ],
                 legend: {
-                    data: ['稼动率', '待料率', '报警率', '换料率', '产能'],
+                    data: ['稼动率', '待料率', '故障率', '换料率', '产能'],
                     textStyle: {
                         color: 'white',
                         fontSize: 14
                     }
                 },
-                series: [
-                    //{
-                    //    type: 'value',
-                    //    name: '待料率',
-                    //    data: [],
-                    //    type: 'bar',
-                    //    stack: 'toral',
-                    //    axisLabel: {
-                    //        formatter: '{value} %'
-                    //    },
-                    //    label: {
-                    //        show: true,
-                    //        color: 'white',
-                    //        fontSize: 12
-                    //    },
-                    //},
-                    //{
-                    //    type: 'value',
-                    //    name: '报警率',
-                    //    data: [],
-                    //    type: 'bar',
-                    //    stack: 'toral',
-                    //    axisLabel: {
-                    //        formatter: '{value} %'
-                    //    },
-                    //    label: {
-                    //        show: true,
-                    //        color: 'white',
-                    //        fontSize: 12
-                    //    },
-                    //},
-                    //{
-                    //    type: 'value',
-                    //    name: '换料率',
-                    //    data: [],
-                    //    type: 'bar',
-                    //    stack: 'toral',
-                    //    axisLabel: {
-                    //        formatter: '{value} %'
-                    //    },
-                    //    label: {
-                    //        show: true,
-                    //        color: 'white',
-                    //        fontSize: 12
-                    //    },
-                    //},
-                    //{
-                    //    type: 'value',
-                    //    name: '产能',
-                    //    data: [],
-                    //    type: 'bar',
-                    //    axisLabel: {
-                    //        formatter: '{value} pcs'
-                    //    },
-                    //    label: {
-                    //        show: true,
-                    //        color: 'white',
-                    //        fontSize: 12
-                    //    },
-                    //    yAxisIndex: 1
-                    //}
-                ]
+                series: []
             };
             this.option_2 = {
                 title: {
@@ -235,15 +174,15 @@
                 toolbox: {
                     right: '10%',
                     feature: {
-                        dataZoom: { yAxisIndex: 'none' }
-                        //mySaveAsExcel: {
-                        //    show: true,
-                        //    title: 'save excel',
-                        //    icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
-                        //    onclick: () => {
-                        //        this.exportExcelTemplate();
-                        //    }
-                        //}
+                        dataZoom: { yAxisIndex: 'none' },
+                        mySaveAsExcel: {
+                            show: true,
+                            title: 'save excel',
+                            icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
+                            onclick: () => {
+                                this.exportExcelTemplate(2);
+                            }
+                        }
                     },
                     iconStyle: {
                         borderColor: "white",
@@ -337,7 +276,15 @@
                 toolbox: {
                     right: '10%',
                     feature: {
-                        dataZoom: { yAxisIndex: 'none' }
+                        dataZoom: { yAxisIndex: 'none' },
+                        mySaveAsExcel: {
+                            show: true,
+                            title: 'save excel',
+                            icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
+                            onclick: () => {
+                                this.exportExcelTemplate(3);
+                            }
+                        }
                     },
                     iconStyle: {
                         borderColor: "white",
@@ -480,15 +427,15 @@
                     var htmlstr = '<thead>< tr >'
                         + '<th style="width: 10%">时段</th>'
                         + '<th style="width: 10%">机种</th>'
-                        + '<th style="width: ' + width +'%">运行时间</th>'
-                        + '<th style="width: ' + width +'%">报警时间</th>'
-                        + '<th style="width: ' + width +'%">待料时间</th>';
+                        + '<th style="width: ' + width + '%">运行时间</th>'
+                        + '<th style="width: ' + width + '%">故障时间</th>'
+                        + '<th style="width: ' + width + '%">待料时间</th>';
                     for (let i = 0; i < flagList.length; i++) {
                         if (i == 3) {
-                            htmlstr += '<th style="width: 10%">报警次数</th>';
+                            htmlstr += '<th style="width: 10%">故障次数</th>';
                         }
                         if (flagList[i]) {
-                            htmlstr = htmlstr + '<th style="width: ' + width +'%">' + this.OEEExtendSetting2[i] + '</th>';
+                            htmlstr = htmlstr + '<th style="width: ' + width + '%">' + this.OEEExtendSetting2[i] + '</th>';
                         }
                     }
 
@@ -612,8 +559,6 @@
                         this.myChart_2.setOption(this.option_3, true);//true重绘
                         this.myChart_2.resize();
 
-                        console.log(outputs_temp);
-
                         this.outputInfo = params.name + "【汇总】";
                         var htmlstr = '<thead>< tr >'
                             + '<th style="width: 10%">时间</th>'
@@ -749,7 +694,7 @@
                 //}
             }
             $.ajax({
-                url: '/ProductionLine/GetProductionLineMachineTree',
+                url: '/ProductionLine/GetProductionLineMachineTreeV1',
                 type: 'GET',
                 async: true,
                 success: function (zNodes) {
@@ -1097,56 +1042,167 @@
                 });
             }
         },
-        exportExcelTemplate() {
+        exportExcelTemplate(mode) {
+            var excelName = "";
             var sheetName = 'sheet1';
             var workbook = {
                 SheetNames: [sheetName],
                 Sheets: {}
             };
-
             var sheet = {};
 
-            sheet['!ref'] = 'A1:' + 'K' + (this.oees_1.length + 1);
-            sheet['!cols'] = [
-                { wch: 10 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 },
-                { wch: 12 }
-            ];
+            if (mode == 1) {
+                var rownum = this.oees_1.length + 1;
+                var colnum = 11;
+                var extendflag = [false, false, false];
+                var colNamelist = ['日期', '班别', '产能(pcs)', '稼动时间(min)', '待料时间(min)', '故障时间(min)', '稼动率(%)', '待料率(%)', '故障率(%)'];
+                for (var item in this.OEEExtendSetting1) {
+                    if (this.OEEExtendSetting1[item] != '') {
+                        extendflag[item] = true;
+                        colNamelist.splice(6 + parseInt(item), 0, this.OEEExtendSetting2[item] + '(min)');
+                        colNamelist.push(this.OEEExtendSetting1[item] + '(%)');
+                        colnum += 2;
+                    }
+                }
+                sheet['!ref'] = 'A1:' + String.fromCharCode(64 + colnum) + rownum;
+                sheet['!cols'] = [];
+                for (let i = 0; i < colnum; i++) {
+                    sheet['!cols'].push({ wch: 14 });
+                    sheet[String.fromCharCode(65 + i) + 1] = { t: "s", v: colNamelist[i] };
+                }
+                this.oees_1.forEach(function (row, i) {
+                    var j = 0;
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.date };
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.shift };
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.outputs };
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: Math.round(row.runTime / 60 * 10) / 10 };
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: Math.round(row.idelTime / 60 * 10) / 10 };
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: Math.round(row.downTime / 60 * 10) / 10 };
+                    if (extendflag[0]) {
+                        sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: Math.round(row.loadMATTime / 60 * 10) / 10 };
+                    }
+                    if (extendflag[1]) {
+                        sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: Math.round(row.reservedOne / 60 * 10) / 10 };
+                    }
+                    if (extendflag[2]) {
+                        sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: Math.round(row.reservedThree / 60 * 10) / 10 };
+                    }
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.runTimeRate };
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.idelTimeRate };
+                    sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.downTimeRate };
+                    if (extendflag[0]) {
+                        sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.loadMATTimeRate };
+                    }
+                    if (extendflag[1]) {
+                        sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.reservedOneTimeRate };
+                    }
+                    if (extendflag[2]) {
+                        sheet[String.fromCharCode(65 + (j++)) + (i + 2)] = { v: row.reservedThreeTimeRate };
+                    }
+                });
+                excelName = zTreeObj.getSelectedNodes()[0].name;
+            }
+            else if (mode == 2) {
+                var rownum = this.option_2.series[0].data.length + 1;
+                var colnum = 7;
+                var extendflag = [false, false, false];
+                var colNamelist = ['日期', '稼动时间(min)', '待料时间(min)', '故障时间(min)', '平均稼动率(%)', '平均待料率(%)', '平均故障率(%)'];
+                sheet['!ref'] = 'A1:' + String.fromCharCode(64 + colnum) + rownum;
+                sheet['!cols'] = [];
+                for (let i = 0; i < colnum; i++) {
+                    sheet['!cols'].push({ wch: 14 });
+                    sheet[String.fromCharCode(65 + i) + 1] = { t: "s", v: colNamelist[i] };
+                };
+                var time_templist = {};
+                for (var item in this.oees_2) {
+                    this.oees_2[item].forEach(function (row_, j) {
+                        if (row_.date in time_templist) {
+                            time_templist[row_.date].autoRunTime += row_.runTime;
+                            time_templist[row_.date].idleTime += row_.idelTime;
+                            time_templist[row_.date].alarmTime += row_.downTime;
+                            time_templist[row_.date].runTimeRate.push(row_.runTimeRate);
+                            time_templist[row_.date].idelTimeRate.push(row_.idelTimeRate);
+                            time_templist[row_.date].downTimeRate.push(row_.downTimeRate);
+                        }
+                        else {
+                            time_templist[row_.date] = {
+                                "autoRunTime": row_.runTime,
+                                "idleTime": row_.idelTime,
+                                "alarmTime": row_.downTime,
+                                "runTimeRate": [row_.runTimeRate],
+                                "idelTimeRate": [row_.idelTimeRate],
+                                "downTimeRate": [row_.downTimeRate],
 
-            sheet['A1'] = { t: "s", v: "日期" };
-            sheet['B1'] = { t: "s", v: "班别" };
-            sheet['C1'] = { t: "s", v: "产能(pcs)" };
-            sheet['D1'] = { t: "s", v: "稼动时间(min)" };
-            sheet['E1'] = { t: "s", v: "待料时间(min)" };
-            sheet['F1'] = { t: "s", v: "报警时间(min)" };
-            sheet['G1'] = { t: "s", v: "换料时间(min)" };
-            sheet['H1'] = { t: "s", v: "稼动率(%)" };
-            sheet['I1'] = { t: "s", v: "待料率(%)" };
-            sheet['J1'] = { t: "s", v: "报警率(%)" };
-            sheet['K1'] = { t: "s", v: "换料率(%)" };
+                            }
+                        }
+                    });
+                };
+                var num = 0;
+                for (var item in time_templist) {
+                    sheet[String.fromCharCode(65) + (num + 2)] = { v: item };
+                    sheet[String.fromCharCode(66) + (num + 2)] = { v: Math.round(time_templist[item].autoRunTime / 60 * 10) / 10 };
+                    sheet[String.fromCharCode(67) + (num + 2)] = { v: Math.round(time_templist[item].idleTime / 60 * 10) / 10 };
+                    sheet[String.fromCharCode(68) + (num + 2)] = { v: Math.round(time_templist[item].alarmTime / 60 * 10) / 10 };
 
-            this.oees_1.forEach(function (row, i) {
-                sheet[String.fromCharCode(65) + (i + 2)] = { v: row.date };
-                sheet[String.fromCharCode(66) + (i + 2)] = { v: row.shift };
-                sheet[String.fromCharCode(67) + (i + 2)] = { v: row.outputs };
-                sheet[String.fromCharCode(68) + (i + 2)] = { v: row.runTime / 60 };
-                sheet[String.fromCharCode(69) + (i + 2)] = { v: row.idelTime / 60 };
-                sheet[String.fromCharCode(70) + (i + 2)] = { v: row.downTime / 60 };
-                sheet[String.fromCharCode(71) + (i + 2)] = { v: row.loadMATTime / 60 };
-                sheet[String.fromCharCode(72) + (i + 2)] = { v: row.runTimeRate };
-                sheet[String.fromCharCode(73) + (i + 2)] = { v: row.idelTimeRate };
-                sheet[String.fromCharCode(74) + (i + 2)] = { v: row.downTimeRate };
-                sheet[String.fromCharCode(75) + (i + 2)] = { v: row.loadMATTimeRate };
-            });
+                    sheet[String.fromCharCode(69) + (num + 2)] = { v: Math.round(time_templist[item].runTimeRate.reduce((acc, val) => acc + val, 0) / time_templist[item].runTimeRate.length * 10) / 10 };
+                    sheet[String.fromCharCode(70) + (num + 2)] = { v: Math.round(time_templist[item].idelTimeRate.reduce((acc, val) => acc + val, 0) / time_templist[item].idelTimeRate.length * 10) / 10 };
+                    sheet[String.fromCharCode(71) + (num + 2)] = { v: Math.round(time_templist[item].downTimeRate.reduce((acc, val) => acc + val, 0) / time_templist[item].downTimeRate.length * 10) / 10 };
+                    num++;
+                }
+                excelName = "chamber汇总"
+            }
+            else if (mode == 3) {
+                var rownum = this.option_3.series[0].data.length + 1;
+                var colnum = 7;
+                var extendflag = [false, false, false];
+                var colNamelist = ['日期', '稼动时间(min)', '待料时间(min)', '故障时间(min)', '平均稼动率(%)', '平均待料率(%)', '平均故障率(%)'];
+                sheet['!ref'] = 'A1:' + String.fromCharCode(64 + colnum) + rownum;
+                sheet['!cols'] = [];
+                for (let i = 0; i < colnum; i++) {
+                    sheet['!cols'].push({ wch: 14 });
+                    sheet[String.fromCharCode(65 + i) + 1] = { t: "s", v: colNamelist[i] };
+                };
 
+                var data_temp = {
+                    chambername: [],
+                    runTime: [],
+                    idelTime: [],
+                    downTime: [],
+                    runTimeRate: [],
+                    idelTimeRate: [],
+                    downTimeRate: []
+                };
+                for (var item in this.oees_2) {
+                    datetimestr = this.oees_2[item][this.EchartsDataIndex].date;
+                    for (var item2 in this.CheckedChamber) {
+                        if (item == this.CheckedChamber[item2].id) {
+                            data_temp.chambername.push(this.CheckedChamber[item2].name);
+                            break;
+                        }
+                    }
+                    data_temp.runTime.push(this.oees_2[item][this.EchartsDataIndex].runTime);
+                    data_temp.idelTime.push(this.oees_2[item][this.EchartsDataIndex].idelTime);
+                    data_temp.downTime.push(this.oees_2[item][this.EchartsDataIndex].downTime);
+                    data_temp.runTimeRate.push(this.oees_2[item][this.EchartsDataIndex].runTimeRate);
+                    data_temp.idelTimeRate.push(this.oees_2[item][this.EchartsDataIndex].idelTimeRate);
+                    data_temp.downTimeRate.push(this.oees_2[item][this.EchartsDataIndex].downTimeRate);
+                }
+                console.log(data_temp);
+                var num = 0;
+                for (var item in data_temp.chambername) {
+                    sheet[String.fromCharCode(65) + (num + 2)] = { v: data_temp.chambername[item] };
+                    sheet[String.fromCharCode(66) + (num + 2)] = { v: Math.round(data_temp.runTime[item] / 60 * 10) / 10 };
+                    sheet[String.fromCharCode(67) + (num + 2)] = { v: Math.round(data_temp.idelTime[item] / 60 * 10) / 10 };
+                    sheet[String.fromCharCode(68) + (num + 2)] = { v: Math.round(data_temp.downTime[item] / 60 * 10) / 10 };
+
+                    sheet[String.fromCharCode(69) + (num + 2)] = { v: data_temp.runTimeRate[item] };
+                    sheet[String.fromCharCode(70) + (num + 2)] = { v: data_temp.idelTimeRate[item] };
+                    sheet[String.fromCharCode(71) + (num + 2)] = { v: data_temp.downTimeRate[item] };
+                    num++;
+                }
+
+                excelName = "chamber" + datetimestr.replace('/', '');;
+            }
             workbook.Sheets[sheetName] = sheet;
 
             // 生成excel的配置项
@@ -1166,7 +1222,7 @@
                 return buf;
             }
 
-            this.openDownloadDialog(blob, '稼动数据.xlsx');
+            this.openDownloadDialog(blob, excelName + '-稼动数据' + '.xlsx');
         },
         openDownloadDialog(url, saveName) {
             if (typeof url == 'object' && url instanceof Blob) {

+ 1133 - 0
ProductionLineMonitor.Web/wwwroot/js/report-form/report-form-v2.js

@@ -0,0 +1,1133 @@
+var vm = new Vue({
+    el: '#app',
+    data: {
+        dom_1: Object,
+        dom_2: Object,
+        myChart_1: Object,//Echarts1图表
+        myChart_2: Object,//Echarts1图表
+        option_1: Object,//Echarts2图表option配置项
+        option_2: Object,//Echarts2图表option配置项
+
+        oees_1: {},//Echarts1图表数据
+        oees_2: {},//Echarts2图表数据
+
+        outputInfo: '',//产能明细表格标题
+
+        period: 0,//0, by shift、day、week、month标识
+        summaryflag: false,//汇总页标识
+        chamberflag: false,//chamber标识(用于隐藏产量)
+
+
+        parentNode: {},//汇总页父节点
+        parentNodes: {},//汇总页所在产线所有设备id
+
+        OEEExtendSetting1: ["稼动率", "待料率", "故障率"], //产能数据类别细分
+        OEEExtendSetting2: ["运行时间", "待料时间", "故障时间", "", "", "", "", "", ""],//产能数据类别细分,
+        PerHourFields: ["autoRunTime", "idleTime", "alarmTime", "loadMATTime", "reservedOne", "reservedThree", "alarmSum", "loadMATSum", "reservedTwo"],
+        OEEFields: ["runTime", "idelTime", "downTime", "loadMATTime", "reservedOne", "reservedThree", "alarmSum", "loadMATSum", "reservedTwoSum"],
+        OEERateFields: ["runTimeRate", "idelTimeRate", "downTimeRate", "loadMATTimeRate", "reservedOneTimeRate", "reservedThreeTimeRate"],
+        color: ['#5b9bd5', '#ed7d31', '#a5a5a5', '#008080', '#f47a75', '#765005', "#8B658B", "#C71585", "#8B2500", "#8B3A62", "#53868B"],//echarts图表配色
+
+        zTreeObj: Object//tree目录对象
+
+    },
+    mounted() {
+        this.init()
+        this.getProductionLineMachineTree()
+    },
+    methods: {
+        //初始化
+        init() {
+            $("#container2").hide();
+            $(".date").datepicker({
+                format: 'yyyy-mm-dd',
+                language: 'zh-CN',
+                autoclose: true,
+                todayBtn: 'linked'
+            }).on('changeDate', function () {
+
+            }).on('keydown', function (e) {
+                return false;
+            });
+
+            //zTreeObj = $.fn.zTree.init($("#treeDemo"), settings, res); //初始化树
+            //zTreeObj.expandAll(true);   //true 节点全部展开、false节点收缩
+
+            this.dom_1 = document.getElementById('container1');
+            this.myChart_1 = echarts.init(this.dom_1, 'vintage', {
+                renderer: 'canvas',
+                useDirtyRect: false
+            });
+            this.dom_2 = document.getElementById('container2');
+            this.myChart_2 = echarts.init(this.dom_2, 'vintage', {
+                renderer: 'canvas',
+                useDirtyRect: false
+            });
+            this.option_1 = {
+                grid: {
+                    left: '4%',
+                    right: '10%',
+                },
+                tooltip: {
+                    trigger: 'axis',
+                    axisPointer: {
+                        type: 'cross',
+                        crossStyle: {
+                            color: '#999'
+                        }
+                    }
+                },
+                toolbox: {
+                    right: '10%',
+                    feature: {
+                        dataZoom: { yAxisIndex: 'none' },
+                        mySaveAsExcel: {
+                            show: true,
+                            title: 'save excel',
+                            icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
+                            onclick: () => {
+                                this.exportExcelTemplate(1);
+                            }
+                        }
+                    },
+                    iconStyle: {
+                        borderColor: "white",
+                    },
+                },
+                color: ['#5b9bd5', '#ed7d31', '#a5a5a5', '#008080', '#546fc6'],
+                xAxis: {
+                    type: 'category',
+                    data: [],
+                    axisLabel: {
+                        show: 'true',
+                        interval: 0,
+                        color: 'white',
+                        fontSize: 14
+                    }
+                },
+                yAxis: [
+                    {
+                        type: 'value',
+                        max: 100,
+                        axisLabel: {
+                            color: 'white',
+                            fontSize: 14,
+                            formatter: '{value} %'
+                        },
+                        splitLine: {
+                            show: true, // 是否显示轴线
+                            lineStyle: {
+                                color: '#e0e6f1', // 刻度线的颜色
+                                width: 1, // 刻度线的宽度
+                                type: 'dashed' // 刻度线的类型
+                            }
+                        }
+                    },
+                    {
+                        type: 'value',
+                        //max: 8000,
+                        axisLabel: {
+                            color: 'white',
+                            fontSize: 14,
+                            formatter: '{value} pcs'
+                        },
+                        splitLine: {
+                            show: false, // 是否显示轴线
+                            lineStyle: {
+                                color: '#e0e6f1', // 刻度线的颜色
+                                width: 1, // 刻度线的宽度
+                                type: 'dashed' // 刻度线的类型
+                            }
+                        }
+                    }
+                ],
+                legend: {
+                    data: ['稼动率', '待料率', '故障率', '换料率', '产能'],
+                    textStyle: {
+                        color: 'white',
+                        fontSize: 14
+                    }
+                },
+                series: []
+            };
+            this.option_2 = {
+                title: {
+                    left: 'center',
+                    text: '单台稼动率明细',
+                    textStyle: {
+                        color: "white"
+                    }
+                },
+                grid: {
+                    left: '10%',
+                    right: '10%',
+                },
+                tooltip: {
+                    trigger: 'axis',
+                    axisPointer: {
+                        type: 'cross',
+                        crossStyle: {
+                            color: '#999'
+                        }
+                    }
+                },
+                toolbox: {
+                    right: '10%',
+                    feature: {
+                        dataZoom: { yAxisIndex: 'none' },
+                        mySaveAsExcel: {
+                            show: true,
+                            title: 'save excel',
+                            icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
+                            onclick: () => {
+                                this.exportExcelTemplate(2);
+                            }
+                        }
+                    },
+                    iconStyle: {
+                        borderColor: "white",
+                    },
+                },
+                color: ['#5b9bd5', '#ed7d31', '#a5a5a5', '#008080', '#546fc6'],
+                xAxis: {
+                    type: 'category',
+                    data: [],
+                    axisLabel: {
+                        color: 'white',
+                        fontSize: 14,
+                        interval: 0
+                        //,rotate: 30
+                    }
+                },
+                yAxis: [
+                    {
+                        type: 'value',
+                        max: function (value) {
+                            var val = Math.ceil(value.max * 1.2);
+                            if (val >= 100) {
+                                return 100;
+                            }
+                            else {
+                                return val;
+                            }
+                        },
+                        axisLabel: {
+                            color: 'white',
+                            fontSize: 14,
+                            formatter: '{value} %'
+                        },
+                        splitLine: {
+                            show: true, // 是否显示轴线
+                            lineStyle: {
+                                color: '#e0e6f1', // 刻度线的颜色
+                                width: 1, // 刻度线的宽度
+                                type: 'dashed' // 刻度线的类型
+                            }
+                        }
+                    },
+                    {
+                        type: 'value',
+                        //max: 8000,
+                        axisLabel: {
+                            color: 'white',
+                            fontSize: 14,
+                            formatter: '{value} %'
+                        },
+                        splitLine: {
+                            show: false, // 是否显示轴线
+                            lineStyle: {
+                                color: '#e0e6f1', // 刻度线的颜色
+                                width: 1, // 刻度线的宽度
+                                type: 'dashed' // 刻度线的类型
+                            }
+                        }
+                    }
+                ],
+                legend: {
+                    data: ['稼动率', '待料率', '故障率'],
+                    textStyle: {
+                        color: 'white',
+                        fontSize: 14
+                    },
+                    "top": "5.5%"
+                },
+                series: []
+            };
+            this.myChart_1.on('click', (params) => this.getOutputs(params, 1));
+            if (this.option_1 && typeof option_1 === 'object') {
+                this.myChart_1.setOption(this.option_1);
+            }
+            this.myChart_2.on('click', (params) => this.getOutputs(params, 2));
+            if (this.option_3 && typeof option_3 === 'object') {
+                this.myChart_2.setOption(this.option_2);
+            }
+            window.addEventListener('resize', this.myChart_1.resize);
+            window.addEventListener('resize', this.myChart_2.resize);
+        },
+        //图表柱子点击事件 function参数(参数[柱子]、图表序号)
+        //chartIndex == 1:
+        // 1)汇总页:获取数据并展示echarts2 + 表格数据更新
+        // 2)单台设备:表格数据更行
+        getOutputs(params, chartIndex) {
+            let _this = this;
+            if (params.componentType === 'series') {
+                if (_this.summaryflag) {
+                    var OEETableData;
+                    var OEEExtendSetting2_Temp = [];
+                    if (chartIndex == 1) {
+                        //汇总页第一个echarts柱状点击事件
+                        var ids = Object.keys(_this.parentNodes).toString();
+                        var OEEExtendSteeings = _this.getOEEExtendSettings(ids);
+                        if (_this.chamberflag) {
+                            OEETableData = { outPutPerHours: [], alarmSum: 0, downTime: 0, idelTime: 0, runTime: 0, date: null, shift: "" };
+                            _this.oees_2 = {};
+                            for (var item in _this.oees_1) {
+                                _this.oees_2[item] = [_this.oees_1[item][params.dataIndex]];
+                            }
+                            for (var item in _this.oees_2) {
+
+                                OEETableData.date = _this.oees_2[item].date;
+                                OEETableData.shift = _this.oees_2[item].shift;
+                                _this.oees_2[item][0].outPutPerHours.forEach(function (row, i) {
+                                    if (OEETableData.outPutPerHours[i] == undefined) {
+                                        OEETableData.outPutPerHours[i] = {
+                                            alarmSum: row.alarmSum,
+                                            alarmTime: row.alarmTime,
+                                            autoRunTime: row.autoRunTime,
+                                            dataTime: row.dataTime,
+                                            idleTime: row.idleTime,
+                                            loadMATSum: row.loadMATSum,
+                                            loadMATTime: row.loadMATTime,
+                                            moduleType: row.moduleType,
+                                            outPut: row.outPut,
+                                            period: row.period,
+                                            reservedOne: row.reservedOne,
+                                            reservedThree: row.reservedThree,
+                                            reservedTwo: row.reservedTwo
+                                        };
+                                    }
+                                    else {
+                                        OEETableData.outPutPerHours[i].alarmSum += row.alarmSum;
+                                        OEETableData.outPutPerHours[i].alarmTime += row.alarmTime;
+                                        OEETableData.outPutPerHours[i].autoRunTime += row.autoRunTime;
+                                        OEETableData.outPutPerHours[i].idleTime += row.idleTime;
+                                        OEETableData.outPutPerHours[i].loadMATSum += row.loadMATSum;
+                                        OEETableData.outPutPerHours[i].loadMATTime += row.loadMATTime;
+                                        OEETableData.outPutPerHours[i].outPut += row.outPut;
+                                        OEETableData.outPutPerHours[i].reservedOne += row.reservedOne;
+                                        OEETableData.outPutPerHours[i].reservedThree += row.reservedThree;
+                                        OEETableData.outPutPerHours[i].reservedTwo += row.reservedTwo;
+                                    }
+                                    OEETableData.alarmSum += row.alarmSum;
+                                    OEETableData.downTime += row.alarmTime;
+                                    OEETableData.idelTime += row.idleTime;
+                                    OEETableData.runTime += row.autoRunTime;
+                                })
+                            }
+                        }
+                        else {
+                            var data_temp = _this.oees_1[Object.keys(_this.oees_1)[0]][params.dataIndex];
+                            OEETableData = data_temp;
+                            $.ajax({
+                                url: '/ReportForm/GetMachineStatisticV4',
+                                type: 'POST',
+                                async: false,
+                                data: {
+                                    "id": ids,
+                                    "startTime": data_temp.startTime,
+                                    "endTime": data_temp.startTime,
+                                    "peroid": _this.period,
+                                    "dayOrnight": data_temp.shift == "白班" ? 1 : 2
+                                },
+                                success: function (rev) {
+                                    if (rev.code == 0) {
+                                        _this.oees_2 = rev.data;
+                                    }
+                                }
+                            })
+                        }
+
+                        var OEE = _this.oees_2;
+                        var x_data = [];
+                        var series_data = {};
+                        var production = [];
+                        for (var item in OEE) {
+                            x_data.push(_this.parentNodes[item]);
+                            OEEExtendSteeings[item][0].forEach(function (row, index) {
+                                if (row != "") {
+                                    if (!(row in series_data)) {
+                                        series_data[row] = [];
+                                    }
+                                }
+                            })
+                        }
+                        for (var item in OEE) {
+                            for (var field in series_data) {
+                                var position = OEEExtendSteeings[item][0].indexOf(field);
+                                if (position != -1) {
+                                    series_data[field].push(OEE[item][0][_this.OEERateFields[position]]);
+                                }
+                                else {
+                                    series_data[field].push(0);
+                                }
+                            }
+                            production.push(OEE[item][0].outputs);
+                        }
+                        _this.option_2.xAxis.data = x_data;
+                        _this.option_2.legend.data = [];
+                        _this.option_2.color = [];
+                        _this.option_2.series = [];
+                        var series_data_keys = Object.keys(series_data);
+                        for (var i in series_data_keys) {
+                            _this.option_2.series.push({
+                                type: 'value',
+                                name: series_data_keys[i],
+                                data: series_data[series_data_keys[i]],
+                                type: 'bar',
+                                stack: "stack1",
+                                label: {
+                                    show: true,
+                                    color: 'white',
+                                    fontSize: 12
+                                }
+                            });
+                            _this.option_2.color.push(_this.color[i]);
+                            _this.option_2.legend.data.push(series_data_keys[i]);
+                        }
+                        if (!_this.chamberflag) {
+                            _this.option_2.series.push({
+                                type: 'value',
+                                name: '产能',
+                                data: production,
+                                type: 'bar',
+                                axisLabel: {
+                                    formatter: '{value} pcs'
+                                },
+                                label: {
+                                    show: true,
+                                    color: 'white',
+                                    fontSize: 12
+                                },
+                                yAxisIndex: 1
+                            })
+                            _this.option_2.legend.data.push('产能');
+                            _this.option_2.color.push('#546fc6');
+                        }
+
+                        _this.option_2.title.text = _this.parentNode.name + " " + params.name.replace("\r\n", " ") + " 单台稼动率明细";
+                        $("#container2").show();
+
+                        _this.myChart_2.clear();
+                        _this.myChart_2.setOption(_this.option_2, true);//true重绘
+                        _this.myChart_2.resize();
+                        OEEExtendSetting2_Temp = _this.OEEExtendSetting2;
+                        _this.outputInfo = params.name;
+                    }
+                    else if (chartIndex == 2) {
+                        //汇总页第二个echarts柱状点击事件
+                        OEETableData = _this.oees_2[Object.keys(_this.oees_2)[params.dataIndex]][0];
+                        if (_this.period == 0) {
+                            _this.outputInfo = OEETableData.date + " " + OEETableData.shift + " 【" + params.name + "】";
+                        }
+                        else {
+                            _this.outputInfo = OEETableData.date + " 【" + params.name + "】";
+                        }
+                        var machineid = _this.findKey(_this.parentNodes, params.name);
+                        OEEExtendSetting2_Temp = _this.getOEEExtendSettings(machineid)[machineid][1];
+                    }
+
+                    var num;
+                    if (_this.chamberflag) {
+                        num = 2;
+                    }
+                    else {
+                        num = 4;
+                    }
+                    OEEExtendSetting2_Temp.forEach(function (row, i) {
+                        if (row != "") {
+                            num++;
+                        }
+                    });
+                    var width = num > 10 ? (100 / num) : 10;
+                    var htmlstr = '<thead>< tr >'
+                        + '<th style="width: ' + width + '%">时段</th>'
+                        + '<th style="width: ' + width + '%">机种</th>';
+                    OEEExtendSetting2_Temp.forEach(function (row, i) {
+                        if (row != "") {
+                            htmlstr += '<th style="width: ' + width + '%">' + row.replace("时间", "时间(min)") + '</th>';
+                        }
+                    });
+                    if (!_this.chamberflag) {
+                        htmlstr = htmlstr
+                            + '<th style = "width: ' + width + '%"> 产能(pcs)</th>'
+                            + '<th style="width: ' + width + '%">TT(s/pcs)</th>';
+                    }
+
+                    var moduleTypelist = [];
+                    for (var item in OEETableData.outPutPerHours) {
+                        if (!moduleTypelist.includes(OEETableData.outPutPerHours[item].moduleType)) {
+                            moduleTypelist.push(OEETableData.outPutPerHours[item].moduleType);
+                        }
+
+                        if (_this.period == 0 || _this.period == 1) {
+                            htmlstr = htmlstr + '<tbody><tr>'
+                                + '<td>' + OEETableData.outPutPerHours[item].period + '</td>'
+                        }
+                        else {
+                            var datetime = moment(OEETableData.outPutPerHours[item].dataTime);
+                            htmlstr = htmlstr + '<tbody><tr>'
+                                + '<td>' + datetime.format('YYYY-MM-DD') + '</td>';
+                        }
+
+                        var datetime = moment(OEETableData.outPutPerHours[item].dataTime);
+                        htmlstr = htmlstr + '<td>' + OEETableData.outPutPerHours[item].moduleType + '</td>';
+                        OEEExtendSetting2_Temp.forEach(function (row, i) {
+                            if (row != "") {
+                                if (i <= 5) {
+                                    htmlstr = htmlstr + '<td>' + Math.round(OEETableData.outPutPerHours[item][_this.PerHourFields[i]] / 60 * 10) / 10 + '</td>';
+                                }
+                                else {
+                                    htmlstr = htmlstr + '<td>' + OEETableData.outPutPerHours[item][_this.PerHourFields[i]] + '</td>';
+                                }
+                            }
+                        })
+
+                        if (!_this.chamberflag) {
+                            htmlstr = htmlstr + '<td>' + OEETableData.outPutPerHours[item].outPut + '</td>'
+                                + '<td>' + OEETableData.outPutPerHours[item].tt + '</td>'
+                                + '</tr></tbody>';
+                        }
+                    }
+                    htmlstr = htmlstr + '<tbody><tr>'
+                        + '<td>合计</td>'
+                        + '<td>' + moduleTypelist.toString() + '</td>';
+                    OEEExtendSetting2_Temp.forEach(function (row, i) {
+                        if (row != "") {
+                            if (i <= 5) {
+                                htmlstr = htmlstr + '<td>' + Math.round(OEETableData[_this.OEEFields[i]] / 60 * 10) / 10 + '</td>';
+                            }
+                            else {
+                                htmlstr = htmlstr + '<td>' + OEETableData[_this.OEEFields[i]] + '</td>';
+                            }
+                        }
+                    })
+                    if (!_this.chamberflag) {
+                        if (OEETableData.outputs != 0) {
+                            TT = Math.round(OEETableData.runTime / OEETableData.outputs * 10) / 10;
+                        }
+                        else {
+                            TT = 0;
+                        }
+                        htmlstr = htmlstr
+                            + '<td>' + OEETableData.outputs + '</td>'
+                            + '<td>' + TT + '</td>'
+                            + '</tr></tbody>';
+                    }
+                    $("#data").html(htmlstr);
+                }
+                else {
+                    //单台设备产能表格更新
+                    var oee = _this.oees_1[Object.keys(this.oees_1)[0]][params.dataIndex];
+                    var outputs = oee.outPutPerHours;
+                    if (_this.period == 0) {
+                        this.outputInfo = oee.date + ' ' + oee.shift;
+                    }
+                    else {
+                        this.outputInfo = oee.date;
+                    }
+                    var num = 4;
+                    _this.OEEExtendSetting2.forEach(function (row, i) {
+                        if (row != "") {
+                            num++;
+                        }
+                    });
+
+                    var width = 100 / num;
+
+                    var htmlstr = '<thead>< tr >'
+                        + '<th style="width: ' + width + '%">时段</th>'
+                        + '<th style="width: ' + width + '%">机种</th>';
+                    _this.OEEExtendSetting2.forEach(function (row, i) {
+                        if (row != "") {
+                            htmlstr += '<th style="width: ' + width + '%">' + row.replace("时间", "时间(min)") + '</th>';
+                        }
+                    });
+                    htmlstr = htmlstr
+                        + '<th style = "width: ' + width + '%"> 产能(pcs)</th>'
+                        + '<th style="width: ' + width + '%">TT(s/pcs)</th>';
+
+                    var moduleTypelist = [];
+                    for (var item in outputs) {
+                        if (!moduleTypelist.includes(outputs[item].moduleType)) {
+                            moduleTypelist.push(outputs[item].moduleType);
+                        }
+
+                        if (_this.period == 0 || _this.period == 1) {
+                            htmlstr = htmlstr + '<tbody><tr>'
+                                + '<td>' + outputs[item].period + '</td>'
+                        }
+                        else {
+                            var datetime = moment(outputs[item].dataTime);
+                            htmlstr = htmlstr + '<tbody><tr>'
+                                + '<td>' + datetime.format('YYYY-MM-DD') + '</td>';
+                        }
+
+                        var datetime = moment(outputs[item].dataTime);
+                        htmlstr = htmlstr + '<td>' + outputs[item].moduleType + '</td>';
+                        _this.OEEExtendSetting2.forEach(function (row, i) {
+                            if (row != "") {
+                                if (i <= 5) {
+                                    htmlstr = htmlstr + '<td>' + Math.round(outputs[item][_this.PerHourFields[i]] / 60 * 10) / 10 + '</td>';
+                                }
+                                else {
+                                    htmlstr = htmlstr + '<td>' + outputs[item][_this.PerHourFields[i]] + '</td>';
+                                }
+                            }
+                        })
+
+                        htmlstr = htmlstr + '<td>' + outputs[item].outPut + '</td>'
+                            + '<td>' + outputs[item].tt + '</td>'
+                            + '</tr></tbody>';
+                    }
+                    htmlstr = htmlstr + '<tbody><tr>'
+                        + '<td>合计</td>'
+                        + '<td>' + moduleTypelist.toString() + '</td>';
+                    _this.OEEExtendSetting2.forEach(function (row, i) {
+                        if (row != "") {
+                            if (i <= 5) {
+                                htmlstr = htmlstr + '<td>' + Math.round(oee[_this.OEEFields[i]] / 60 * 10) / 10 + '</td>';
+                            }
+                            else {
+                                htmlstr = htmlstr + '<td>' + oee[_this.OEEFields[i]] + '</td>';
+                            }
+                        }
+                    })
+                    var TT = 0;
+                    if (oee.outputs != 0) {
+                        TT = Math.round(oee.runTime / oee.outputs * 10) / 10;
+                    }
+                    htmlstr = htmlstr
+                        + '<td>' + oee.outputs + '</td>'
+                        + '<td>' + TT + '</td>'
+                        + '</tr></tbody>';
+                    $("#data").html(htmlstr);
+                }
+            }
+        },
+        //获取产线设备数据并更新目录
+        getProductionLineMachineTree() {
+            let _this = this;
+            var setting = {
+                view: {
+                    showIcon: false
+                },
+                callback: {
+                    onClick: function (event, treeId, treeNode) {
+                        _this.selected();
+
+                    }
+                }
+            };
+            ///下拉框
+            var setting1 = {
+                check: {
+                    enable: true,
+                    nocheckInherit: true,
+                    chkboxType: { "Y": "ps", "N": "ps" }
+                }
+            }
+            $.ajax({
+                url: '/ProductionLine/GetProductionLineMachineTreeV1',
+                type: 'GET',
+                async: false,
+                success: function (zNodes) {
+                    _this.zTreeObj = $.fn.zTree.init($('#productionLineTree'), setting, zNodes);
+                }
+            });
+
+        },
+        //查询按钮点击事件,获取数据并更行echarts1
+        getOEES() {
+            let _this = this
+            var nodes = _this.zTreeObj.getSelectedNodes()[0];
+            if (nodes == null) {
+                alert("请选择设备!");
+                return;
+            }
+            if ($("#selectPeroid").val() == 0 && Math.floor(Math.abs(Date.parse($("#date2").val()) - Date.parse($("#date1").val())) / (1000 * 3600 * 24)) > 10) {
+                alert("按班统计时,不可超过10日!!");
+                return;
+            }
+            if ($("#selectPeroid").val() == 1 && Math.floor(Math.abs(Date.parse($("#date2").val()) - Date.parse($("#date1").val())) / (1000 * 3600 * 24)) > 20) {
+                alert("按天统计时,不可超过20日!!");
+                return;
+            }
+            _this.period = $("#selectPeroid").val();
+            _this.chamberflag = false;
+            if (nodes.name == "汇总") {
+                _this.summaryflag = true;
+                _this.parentNodes = {};
+                var parentNodes = nodes.getParentNode();
+                _this.parentNode = parentNodes;
+                if (parentNodes.name == "Y5 Chamber") {
+                    _this.chamberflag = true;
+                }
+                parentNodes.children.forEach(function (item) {
+                    if (item.name != "汇总") {
+                        _this.parentNodes[item.id] = item.name;
+                    }
+                })
+            }
+            else {
+                $("#container2").hide();
+                _this.summaryflag = false;
+                if (nodes.name.includes("Chamber")) {
+                    _this.chamberflag = true;
+                }
+            }
+
+            var OEESettings = _this.getOEEExtendSettings(nodes.id);
+            if (!_this.chamberflag) {
+                _this.OEEExtendSetting1 = OEESettings[nodes.id][0];
+                _this.OEEExtendSetting2 = OEESettings[nodes.id][1];
+            }
+            else {
+                _this.OEEExtendSetting1 = OEESettings[nodes.id.split(',')[0]][0];
+                _this.OEEExtendSetting2 = OEESettings[nodes.id.split(',')[0]][1];
+            }
+            _this.period = $("#selectPeroid").val();
+
+            $.ajax({
+                url: '/ReportForm/GetMachineStatisticV4',
+                type: 'POST',
+                async: true,
+                data: {
+                    "id": nodes.id,
+                    "startTime": $("#date1").val(),
+                    "endTime": $("#date2").val(),
+                    "peroid": _this.period,
+                    "dayOrnight": 0
+                },
+                success: function (rev) {
+                    if (rev.code === 0) {
+                        _this.oees_1 = rev.data;
+                        _this.option_1.series = [];
+                        _this.option_1.legend.data = [];
+                        _this.option_1.color = [];
+                        var xData = [];
+                        var devicenum = 0;
+                        var production = [];
+                        var agvdatalist = [[], [], [], [], [], []];
+                        for (var i in rev.data) {
+                            for (var k in rev.data[i]) {
+                                if (devicenum == 0) {
+                                    if ($("#selectPeroid").val() == 0) {
+                                        xData.push(rev.data[i][k].date + '\r\n' + rev.data[i][k].shift);
+                                    }
+                                    else {
+                                        xData.push(rev.data[i][k].date);
+                                    }
+                                    agvdatalist[0].push(rev.data[i][k].runTimeRate);
+                                    agvdatalist[1].push(rev.data[i][k].idelTimeRate);
+                                    agvdatalist[2].push(rev.data[i][k].downTimeRate);
+                                    agvdatalist[3].push(rev.data[i][k].loadMATTimeRate);
+                                    agvdatalist[4].push(rev.data[i][k].reservedOneTimeRate);
+                                    agvdatalist[5].push(rev.data[i][k].reservedThreeTimeRate);
+                                    production.push(rev.data[i][k].outputs);
+                                }
+                                else {
+                                    agvdatalist[0][k] += rev.data[i][k].runTimeRate;
+                                    agvdatalist[1][k] += rev.data[i][k].idelTimeRate;
+                                    agvdatalist[2][k] += rev.data[i][k].downTimeRate;
+                                    agvdatalist[3][k] += rev.data[i][k].loadMATTimeRate;
+                                    agvdatalist[4][k] += rev.data[i][k].reservedOneTimeRate;
+                                    agvdatalist[5][k] += rev.data[i][k].reservedThreeTimeRate;
+                                    production[k] += rev.data[i][k].outputs;
+                                }
+                            }
+                            devicenum++;
+                        }
+
+                        for (let i = 0; i < agvdatalist.length; i++) {
+                            for (let j = 0; j < agvdatalist[i].length; j++) {
+                                agvdatalist[i][j] = (agvdatalist[i][j] / devicenum).toFixed(2);
+                            }
+                        }
+
+
+                        var num = 0;
+                        _this.OEEExtendSetting1.forEach(function (row, i) {
+                            if (row != "") {
+                                _this.option_1.series.push({
+                                    type: 'value',
+                                    name: row,
+                                    data: agvdatalist[i],
+                                    type: 'bar',
+                                    stack: "stack1",
+                                    label: {
+                                        show: true,
+                                        color: 'white',
+                                        fontSize: 12
+                                    }
+                                })
+                                _this.option_1.legend.data.push(row);
+                                _this.option_1.color.push(_this.color[num]);
+                                num++;
+                            }
+                        })
+                        if (!_this.chamberflag) {
+                            _this.option_1.series.push({
+                                type: 'value',
+                                name: '产能',
+                                data: production,
+                                type: 'bar',
+                                axisLabel: {
+                                    formatter: '{value} pcs'
+                                },
+                                label: {
+                                    show: true,
+                                    color: 'white',
+                                    fontSize: 12
+                                },
+                                yAxisIndex: 1
+                            })
+                            _this.option_1.legend.data.push('产能');
+                            _this.option_1.color.push('#546fc6');
+                        }
+                        _this.option_1.xAxis.data = xData;
+                        _this.myChart_1.clear();
+                        _this.myChart_1.setOption(_this.option_1, true);//true重绘
+
+                        var param_temp = {
+                            componentType: 'series',
+                            name: _this.option_1.xAxis.data.slice(-1)[0],
+                            dataIndex: _this.option_1.xAxis.data.length - 1
+                        }
+                        _this.getOutputs(param_temp, 1);
+
+                    } else {
+                        alert(rev.message);
+                    }
+                }
+            });
+
+        },
+        //导出产能数据  function参数(图表序号)
+        exportExcelTemplate(chartIndex) {
+            let _this = this;
+            var excelName = "";
+            var sheetName = 'sheet1';
+            var workbook = {
+                SheetNames: [sheetName],
+                Sheets: {}
+            };
+            var sheet = {};
+
+            if (chartIndex == 1) {
+                var colNamelist = ['日期'];
+                var colTimeFields = [];
+                var colRateFields = [];
+                var TimeDataList = [];
+                var RateDataList = [];
+                var flag = 0;
+                if (!_this.chamberflag) {
+                    colNamelist.push('产量(pcs)');
+                }
+
+                _this.OEEExtendSetting2.forEach(function (row, i) {
+                    if (i < 6 && row != "") {
+                        colNamelist.push(row);
+                        colTimeFields.push(_this.OEEFields[i]);
+                        TimeDataList.push([]);
+                    }
+                })
+                _this.OEEExtendSetting1.forEach(function (row, i) {
+                    if (row != "") {
+                        colNamelist.push(row);
+                        colRateFields.push(_this.OEERateFields[i]);
+                        RateDataList.push([]);
+                    }
+                })
+                var devicenum = 0;
+                var dateproductionlist = [[], []];
+                var oee_data = _this.oees_1;
+                for (var item in oee_data) {
+                    for (var k in oee_data[item]) {
+                        if (devicenum == 0) {
+                            if (_this.period == 0) {
+                                dateproductionlist[0].push(oee_data[item][k].date + ' ' + oee_data[item][k].shift);
+                            }
+                            else {
+                                dateproductionlist[0].push(oee_data[item][k].date);
+                            }
+
+                            dateproductionlist[1].push(oee_data[item][k].outputs);
+                        }
+                        colTimeFields.forEach(function (row, i) {
+                            if (TimeDataList[i][k] == undefined) {
+                                TimeDataList[i][k] = parseFloat(oee_data[item][k][row]);
+                            }
+                            else {
+                                TimeDataList[i][k] += parseFloat(oee_data[item][k][row]);
+                            }
+                        })
+                        colRateFields.forEach(function (row, i) {
+                            if (RateDataList[i][k] == undefined) {
+                                RateDataList[i][k] = parseFloat(oee_data[item][k][row]);
+                            }
+                            else {
+                                RateDataList[i][k] += parseFloat(oee_data[item][k][row]);
+                            }
+                        })
+                    }
+                    devicenum++;
+                }
+
+                var rownum = dateproductionlist[0].length + 1;
+                sheet['!ref'] = 'A1:' + String.fromCharCode(64 + colNamelist.length) + rownum;
+                sheet['!cols'] = [];
+                for (let i = 0; i < colNamelist.length; i++) {
+                    sheet['!cols'].push({ wch: 14 });
+                    sheet[String.fromCharCode(65 + i) + 1] = { t: "s", v: colNamelist[i].replace("时间", "时间(min)").replace("率", "率(%)") };
+                }
+
+                for (var i in dateproductionlist[0]) {
+                    var j = 0;
+                    sheet[String.fromCharCode(65 + (j++)) + (parseInt(i) + 2)] = { v: dateproductionlist[0][i] };
+                    if (!_this.chamberflag) {
+                        sheet[String.fromCharCode(65 + (j++)) + (parseInt(i) + 2)] = { v: dateproductionlist[1][i] };
+                    }
+                    for (var k in TimeDataList) {
+                        sheet[String.fromCharCode(65 + (j++)) + (parseInt(i) + 2)] = { v: Math.round(TimeDataList[k][i] / 60 * 10) / 10 };
+                    }
+                    for (var k in RateDataList) {
+                        sheet[String.fromCharCode(65 + (j++)) + (parseInt(i) + 2)] = { v: Math.round(RateDataList[k][i] / devicenum * 100) / 100 };
+                    }
+                }
+                excelName = _this.parentNode.name + " " + _this.zTreeObj.getSelectedNodes()[0].name;
+            }
+            else if (chartIndex == 2) {
+                var colTimeNames = [];
+                var colRateNames = [];
+                var colNamelist = ['设备', '日期'];
+                if (!_this.chamberflag) {
+                    colNamelist.push('产量(pcs)');
+                }
+                var oee_data = _this.oees_2;
+                var ids = Object.keys(_this.parentNodes).toString();
+                var OEEExtendSteeings = _this.getOEEExtendSettings(ids);
+                for (var item in OEEExtendSteeings) {
+                    for (var j in OEEExtendSteeings[item][1]) {
+                        var str_temp = OEEExtendSteeings[item][1][j];
+                        if (str_temp != "" && j < 6 && colTimeNames.indexOf(str_temp) == -1) {
+                            colTimeNames.push(str_temp);
+                        }
+                    }
+                    for (var j in OEEExtendSteeings[item][0]) {
+                        var str_temp = OEEExtendSteeings[item][0][j];
+                        if (str_temp != "" && colRateNames.indexOf(str_temp) == -1) {
+                            colRateNames.push(str_temp);
+                        }
+                    }
+                }
+                colTimeNames.forEach(function (row) {
+                    colNamelist.push(row);
+                })
+                colRateNames.forEach(function (row) {
+                    colNamelist.push(row);
+                })
+
+                var rownum = Object.keys(oee_data).length + 1;
+                sheet['!ref'] = 'A1:' + String.fromCharCode(64 + colNamelist.length) + rownum;
+                sheet['!cols'] = [];
+                for (let i = 0; i < colNamelist.length; i++) {
+                    sheet['!cols'].push({ wch: 14 });
+                    sheet[String.fromCharCode(65 + i) + 1] = { t: "s", v: colNamelist[i].replace("时间", "时间(min)").replace("率", "率(%)") };
+                }
+
+
+                var row_Index = 0;
+                for (var item in oee_data) {
+                    var j = 0;
+                    sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: _this.parentNodes[item] };
+                    if (_this.period == 0) {
+                        sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: oee_data[item][0].date + ' ' + oee_data[item][0].shift };
+                    }
+                    else {
+                        sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: oee_data[item][0].date };
+                    }
+                    if (!_this.chamberflag) {
+                        sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: oee_data[item][0].outputs };
+                    }
+                    colTimeNames.forEach(function (row, i) {
+                        var index = OEEExtendSteeings[item][1].indexOf(row);
+                        if (index != -1) {
+                            sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: oee_data[item][0][_this.OEEFields[index]] };
+                        }
+                        else {
+                            sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: 0 };
+                        }
+                    })
+                    colRateNames.forEach(function (row, i) {
+                        var index = OEEExtendSteeings[item][0].indexOf(row);
+                        if (index != -1) {
+                            sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: oee_data[item][0][_this.OEERateFields[index]] };
+                        }
+                        else {
+                            sheet[String.fromCharCode(65 + (j++)) + (row_Index + 2)] = { v: 0 };
+                        }
+                    })
+                    row_Index++;
+                }
+                excelName = _this.parentNode.name + " 单台";
+            }
+
+            workbook.Sheets[sheetName] = sheet;
+
+            // 生成excel的配置项
+            var wopts = {
+                bookType: 'xlsx', // 要生成的文件类型
+                bookSST: false, // 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
+                type: 'binary'
+            };
+            var wbout = XLSX.write(workbook, wopts);
+            var blob = new Blob([s2ab(wbout)], { type: "application/octet-stream" });
+
+            // 字符串转ArrayBuffer
+            function s2ab(s) {
+                var buf = new ArrayBuffer(s.length);
+                var view = new Uint8Array(buf);
+                for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
+                return buf;
+            }
+
+            this.openDownloadDialog(blob, excelName + '-稼动数据' + '.xlsx');
+        },
+        openDownloadDialog(url, saveName) {
+            if (typeof url == 'object' && url instanceof Blob) {
+                url = URL.createObjectURL(url); // 创建blob地址
+            }
+            var aLink = document.createElement('a');
+            aLink.href = url;
+            aLink.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
+            var event;
+            if (window.MouseEvent) event = new MouseEvent('click');
+            else {
+                event = document.createEvent('MouseEvents');
+                event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+            }
+            aLink.dispatchEvent(event);
+        },
+        //根据选择的period更新时间选择框
+        selected() {
+            var v = $("#selectPeroid").val();
+            if (v == 0 || v == 1 || v == 2 || v == "") {
+                $(".date").datepicker("destroy");
+                $(".date").datepicker({
+                    minViewMode: 'days',
+                    format: 'yyyy-mm-dd',
+                    language: 'zh-CN',
+                    autoclose: true,
+                    todayBtn: 'linked'
+                }).on('changeDate', function () {
+
+                }).on('keydown', function (e) {
+                    return false;
+                });
+                var date1;
+                if (v == 0) {
+                    date1 = new Date(new Date().setDate(new Date().getDate() - 7));
+                }
+                else if (v == 1) {
+                    date1 = new Date(new Date().setDate(new Date().getDate() - 14));
+                }
+                else if (v == 2) {
+                    date1 = new Date(new Date().setDate(new Date().getDate() - 21));
+                }
+                var date2 = new Date(new Date().setDate(new Date().getDate() - 1));
+                var date1_1 = moment(date1);
+                var date2_1 = moment(date2);
+                $("#date1").datepicker('update', date1_1.format('YYYY-MM-DD'));
+                $("#date2").datepicker('update', date2_1.format('YYYY-MM-DD'));
+            }
+            else {
+                $(".date").datepicker("destroy");
+                $(".date").datepicker({
+                    minViewMode: 'months',
+                    format: 'yyyy-mm',
+                    language: 'zh-CN',
+                    autoclose: true,
+                    todayBtn: 'linked'
+                }).on('changeDate', function () {
+
+                }).on('keydown', function (e) {
+                    return false;
+                });
+                var date1 = new Date(new Date().setDate(new Date().getDate() - 30));
+                var date2 = new Date(new Date().setDate(new Date().getDate() - 1));
+                var date1_1 = moment(date1);
+                var date2_1 = moment(date2);
+                $("#date1").datepicker('update', date1_1.format('YYYY-MM'));
+                $("#date2").datepicker('update', date2_1.format('YYYY-MM'));
+            }
+        },
+        //获取设备的自定义标签信息 参数ids(id1,id2,……,id3,id4)
+        getOEEExtendSettings(ids) {
+            var temp = {};
+            var _this = this;
+            if (ids != "") {
+                $.ajax({
+                    url: '/ReportForm/GetOEEExtendSetting',
+                    type: 'POST',
+                    async: false,
+                    data: {
+                        "ids": ids
+                    },
+                    success: function (rst) {
+                        if (rst.code == 0) {
+                            for (var item in rst.data) {
+                                var OEEExtendSetting1_temp = ["稼动率", "待料率", "故障率"];
+                                var OEEExtendSetting2_temp = ["运行时间", "待料时间", "故障时间"];
+                                var templist1 = ["", "", ""];
+                                var templist2 = ["", "", "", "", "", ""];
+                                var settinglist = rst.data[item].split(",");
+                                if (settinglist.length == 5) {
+                                    for (let i = 0; i < 5; i = i + 2) {
+                                        if (settinglist[i] != "") {
+                                            templist1[i / 2] = settinglist[i].replace("时间", "率");
+                                            templist2[i / 2] = settinglist[i];
+                                        }
+                                    }
+                                    for (let i = 1; i < 5; i = i + 2) {
+                                        if (settinglist[i] != "") {
+                                            templist2[(i - 1) / 2 + 4] = settinglist[i];
+                                        }
+                                    }
+                                }
+                                templist2[3] = _this.chamberflag ? "" : "报警次数";
+                                temp[item] = [OEEExtendSetting1_temp.concat(templist1), OEEExtendSetting2_temp.concat(templist2)];
+                            }
+                        }
+                    }
+                })
+            }
+            return temp;
+        },
+        //根据value获取key
+        findKey(obj, value, compare = (a, b) => a === b) {
+            Object.keys(obj).find(k => {
+                compare(obj[k], value)
+            })
+            return Object.keys(obj).find(k => compare(obj[k], value))
+        }
+    },
+    filters: {
+
+    },
+    created: function () {
+
+    },
+    destroyed: function () {
+
+    }
+})

Some files were not shown because too many files changed in this diff