baowei 3 nedēļas atpakaļ
vecāks
revīzija
bb934af987

+ 27 - 1
ProductionLineMonitor.Application/Services/OEEService/Dtos/MachineOEEInfo.cs

@@ -40,6 +40,8 @@ namespace ProductionLineMonitor.Application.Services.OEEService.Dtos
         public int DownTime { get; private set; }
         public int TotalTime { get; private set; }
         public int LoadMATTime { get; private set; }
+        public int ReservedOne { get; private set; }
+        public int ReservedThree { get; private set; }
         public double IdelTimeRate
         {
             get
@@ -84,6 +86,28 @@ namespace ProductionLineMonitor.Application.Services.OEEService.Dtos
                 return Math.Round(LoadMATTime * 1.0 / TotalTime * 100, 2);
             }
         }
+        public double ReservedOneTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(ReservedOne * 1.0 / TotalTime * 100, 2);
+            }
+        }
+        public double ReservedThreeTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(ReservedThree * 1.0 / TotalTime * 100, 2);
+            }
+        }
         public void CalculateOEE()
         {
             Outputs = OutPutPerHours.Sum(s => s.OutPut.Value);
@@ -91,13 +115,15 @@ 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 == null ? 0 : s.ReservedOne.Value);
+            ReservedThree = OutPutPerHours.Sum(s => s.ReservedThree == null ? 0 : s.ReservedThree.Value);
             TotalTime = OutPutPerHours.Count() * 60 * 60;
         }
     }
 
     public class MachineOEE
     {
-        public List<MachineOEEInfo> Infos { get; set; } 
+        public List<MachineOEEInfo> Infos { get; set; }
             = new List<MachineOEEInfo>();
     }
 }

+ 134 - 0
ProductionLineMonitor.Application/Services/OEEService/Dtos/MachineOEEInfoByPeriod.cs

@@ -0,0 +1,134 @@
+using ProductionLineMonitor.Core.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ProductionLineMonitor.Application.Services.OEEService.Dtos
+{
+    public class MachineOEEInfoByPeriod
+    {
+        public List<MachineOutPutPerHour> OutPutPerHours { get; set; }
+            = new List<MachineOutPutPerHour>();
+        public DateTime StartTime { get; set; }
+        public DateTime EndTime { get; set; }
+        public string Date
+        {
+            get
+            {
+                return StartTime.ToString("MM/dd");
+            }
+        }
+        public string Shift
+        {
+            get
+            {
+                if (StartTime.Hour == 8)
+                {
+                    return "白班";
+                }
+                if (StartTime.Hour == 20)
+                {
+                    return "夜班";
+                }
+                return "";
+            }
+        }
+        public int Outputs { get; private set; }
+        public int RunTime { get; private set; }
+        public int IdelTime { get; private set; }
+        public int DownTime { get; private set; }
+        public int TotalTime { get; private set; }
+        public int LoadMATTime { get; private set; }
+        public int ReservedOne { get; private set; }
+        public int ReservedThree { get; private set; }
+        public double IdelTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(IdelTime * 1.0 / TotalTime * 100, 2);
+            }
+        }
+        public double RunTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(RunTime * 1.0 / TotalTime * 100, 2);
+            }
+        }
+        public double DownTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(DownTime * 1.0 / TotalTime * 100, 2);
+            }
+        }
+        public double LoadMATTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(LoadMATTime * 1.0 / TotalTime * 100, 2);
+            }
+        }
+        public double ReservedOneTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(ReservedOne * 1.0 / TotalTime * 100, 2);
+            }
+        }
+        public double ReservedThreeTimeRate
+        {
+            get
+            {
+                if (TotalTime == 0)
+                {
+                    return 0;
+                }
+                return Math.Round(ReservedThree * 1.0 / TotalTime * 100, 1);
+            }
+        }
+        public void CalculateOEE(int i, int daysnum)
+        {
+            Outputs = OutPutPerHours.Sum(s => s.OutPut.Value);
+            RunTime = OutPutPerHours.Sum(s => s.AutoRunTime.Value);
+            IdelTime = OutPutPerHours.Sum(s => s.IdleTime.Value);
+            DownTime = OutPutPerHours.Sum(s => s.AlarmTime.Value);
+            LoadMATTime = OutPutPerHours.Sum(s => s.LoadMATTime.Value);
+            if (i == 1)
+            {
+                TotalTime = OutPutPerHours.Count() * 60 * 60;
+            }
+            else
+            {
+                TotalTime = OutPutPerHours.Count() * 60 * 60 * 24 * daysnum;
+            }
+        }
+    }
+
+    public class MachineOEEByPeroid
+    {
+        public List<MachineOEEInfoByPeriod> Infos { get; set; }
+            = new List<MachineOEEInfoByPeriod>();
+    }
+}

+ 2 - 0
ProductionLineMonitor.Application/Services/OEEService/IOEEService.cs

@@ -8,5 +8,7 @@ namespace ProductionLineMonitor.Application.Services.OEEService
     public interface IOEEService
     {
         List<MachineOEEInfo> GetOEE(string machineId, string startDate, string endDate);
+
+        Dictionary<string, List<MachineOEEInfoByPeriod>> GetOEEByPeriod(string machineIds, string startDate, string endDate, int peroid);
     }
 }

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

@@ -1,6 +1,9 @@
 using AutoMapper;
 using Core.Dtos;
+using Newtonsoft.Json;
+using NPOI.SS.Formula.Functions;
 using NPOI.Util;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
 using ProductionLineMonitor.Application.Services.OEEService.Dtos;
 using ProductionLineMonitor.Core.IRepositories;
 using ProductionLineMonitor.Core.Models;
@@ -22,10 +25,10 @@ namespace ProductionLineMonitor.Application.Services.OEEService
         public List<MachineOEEInfo> GetOEE(string machineId, string startDate, string endDate)
         {
             List<MachineOEEInfo> OEES = new List<MachineOEEInfo>();
-            
-            DateTime startTime = DateTime.Parse($"{startDate} 08:00:00");  
+
+            DateTime startTime = DateTime.Parse($"{startDate} 08:00:00");
             DateTime endTime = DateTime.Parse($"{endDate} 08:00:00").AddDays(1);
-            
+
             List<MachineOutPutPerHour> outputs = _unitOfWork.MachineOutPutPerHourRepository
                 .GetList(
                     x =>
@@ -33,7 +36,7 @@ namespace ProductionLineMonitor.Application.Services.OEEService
                     x.DataTime >= startTime &&
                     x.DataTime < endTime)
                 .OrderBy(
-                    o => 
+                    o =>
                     o.DataTime)
                 .ToList();
 
@@ -49,8 +52,192 @@ namespace ProductionLineMonitor.Application.Services.OEEService
                 machineOEE.CalculateOEE();
                 OEES.Add(machineOEE);
             }
-
             return OEES;
         }
+
+        /// <summary>
+        /// 
+        /// </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)
+        {
+            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 == 1)
+            {
+                startTime = DateTime.Parse($"{startDate} 08:00:00");
+                endTime = DateTime.Parse($"{endDate} 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, 0);
+                        OEES.Add(machineOEE);
+                    }
+                    OEES_Dic.Add(item, OEES);
+                }
+                return OEES_Dic;
+            }
+            else if (peroid == 2)
+            {
+                startTime = DateTime.Parse($"{startDate} 08:00:00");
+                endTime = DateTime.Parse($"{endDate} 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),
+                                    CreateTime = outputperhours[0].CreateTime,
+                                    UpdateTime = outputperhours[0].UpdateTime
+                                };
+                                outputhourslist.Add(machineoutputhour);
+                            }
+                        }
+
+                        MachineOEEInfoByPeriod machineOEE = new MachineOEEInfoByPeriod
+                        {
+                            StartTime = i,
+                            EndTime = tempTime1,
+                            OutPutPerHours = outputhourslist
+                        };
+                        machineOEE.CalculateOEE(peroid, 1);
+                        OEES.Add(machineOEE);
+                    }
+                    OEES_Dic.Add(item, OEES);
+                }
+
+                return OEES_Dic;
+            }
+            else
+            {
+                startTime = DateTime.Parse($"{startDate}-01 08:00:00");
+                endTime = DateTime.Parse($"{endDate}-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),
+                                    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;
+            }
+
+
+        }
     }
 }

+ 3 - 0
ProductionLineMonitor.Core/Dtos/EQPData.cs

@@ -260,6 +260,9 @@ namespace Core.Dtos
         public int OutPut { get; set; }
         public string Period { get; set; }
         public int TargetTT { get; set; }
+        public int ReservedOne { get; set; }
+        public int ReservedTwo { get; set; }
+        public int ReservedThree { get; set; }
     }
     [Serializable]
     public class PowerConsumptns

+ 15 - 1
ProductionLineMonitor.Core/Models/MachineOutPutPerHour.cs

@@ -1,4 +1,5 @@
-using System;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations.Schema;
 using System.Text;
@@ -71,6 +72,18 @@ namespace ProductionLineMonitor.Core.Models
         /// 换料时间
         /// </summary>
         public int? LoadMATTime { get; set; }
+        /// <summary>
+        /// 备用1
+        /// </summary>
+        public int? ReservedOne { get; set; } = 0;
+        /// <summary>
+        /// 备用2
+        /// </summary>
+        public int? ReservedTwo { get; set; } = 0;
+        /// <summary>
+        /// 备用3
+        /// </summary>
+        public int? ReservedThree { get; set; } = 0;
 
         public double TT
         {
@@ -93,5 +106,6 @@ namespace ProductionLineMonitor.Core.Models
                 return $"{hour}:00~{hour + 1}:00";
             }
         }
+
     }
 }

+ 6 - 0
ProductionLineMonitor.Core/Services/External/ExternalService.cs

@@ -58,6 +58,9 @@ namespace ProductionLineMonitor.Core.Services
                     outPutPerHour.AlarmSum = dto.OutPuts[i].AlarmSum;
                     outPutPerHour.LoadMATTime = dto.OutPuts[i].LoadMATTime;
                     outPutPerHour.LoadMATSum = dto.OutPuts[i].LoadMATSum;
+                    outPutPerHour.ReservedOne = dto.OutPuts[i].ReservedOne;
+                    outPutPerHour.ReservedTwo = dto.OutPuts[i].ReservedTwo;
+                    outPutPerHour.ReservedThree = dto.OutPuts[i].ReservedThree;
                     outPutPerHour.CreateTime = DateTime.Now;
                     outPutPerHour.UpdateTime = DateTime.Now;
                     _unitOfWork.MachineOutPutPerHourRepository.Create(outPutPerHour);
@@ -77,6 +80,9 @@ namespace ProductionLineMonitor.Core.Services
                     outPut.AlarmSum = dto.OutPuts[i].AlarmSum;
                     outPut.LoadMATTime = dto.OutPuts[i].LoadMATTime;
                     outPut.LoadMATSum = dto.OutPuts[i].LoadMATSum;
+                    outPut.ReservedOne = dto.OutPuts[i].ReservedOne;
+                    outPut.ReservedTwo = dto.OutPuts[i].ReservedTwo;
+                    outPut.ReservedThree = dto.OutPuts[i].ReservedThree;
                     outPut.MachineId = machine.Id;
                     outPut.UpdateTime = DateTime.Now;
                 }

+ 34 - 4
ProductionLineMonitor.Core/Services/ProductionLine/ProductionLineCoreService.cs

@@ -1,6 +1,8 @@
 using AutoMapper;
 using Microsoft.EntityFrameworkCore.Infrastructure;
 using Microsoft.Extensions.Options;
+using Newtonsoft.Json;
+using Org.BouncyCastle.Crypto.IO;
 using ProductionLineMonitor.Core.Dtos;
 using ProductionLineMonitor.Core.IRepositories;
 using ProductionLineMonitor.Core.Models;
@@ -134,7 +136,7 @@ namespace ProductionLineMonitor.Core.Services
             var fog = productionLineDto.Machines.FirstOrDefault(x => x.Type == "FOG");
             if (fog != null)
             {
-                productionLineDto.Statistics= fog.Statistics;   
+                productionLineDto.Statistics = fog.Statistics;
             }
 
             return productionLineDto;
@@ -160,15 +162,43 @@ namespace ProductionLineMonitor.Core.Services
                    .GetList(x => x.ProductionLineId == production.Id)
                    .OrderBy(o => o.ProductionLineOrder).ToList();
 
-                foreach (var machine in machines)
+                if (production.Name != "H5 Chamber")
+                {
+                    foreach (var machine in machines)
+                    {
+                        node.Children.Add(new Node()
+                        {
+                            Id = machine.Id.ToString(),
+                            Name = machine.Name,
+                            Children = null
+                        });
+                    }
+                }
+                else
                 {
                     node.Children.Add(new Node()
                     {
-                        Id = machine.Id.ToString(),
-                        Name = machine.Name,
+                        Id = "ChamberTotal",
+                        Name = "Chamber汇总",
                         Children = null
                     });
+
+                    List<string> chamberids = new List<string>();
+
+                    foreach (var machine in machines)
+                    {
+                        chamberids.Add(machine.Id.ToString());
+                        node.Children.Add(new Node()
+                        {
+                            Id = machine.Id.ToString(),
+                            Name = machine.Name,
+                            Children = null
+                        });
+                    }
+                    node.Children[0].Id = JsonConvert.SerializeObject(String.Join(",", chamberids));
                 }
+
+
                 nodes.Add(node);
             }
             tree.Nodes = nodes;

+ 0 - 1
ProductionLineMonitor.Web/Config.cs

@@ -4,6 +4,5 @@
     {
         public static string SafeguardUrl { get; set; }
 
-        public static string SafeguardUsername { get; set; }
     }
 }

+ 21 - 2
ProductionLineMonitor.Web/Controllers/ReportFormController.cs

@@ -19,7 +19,7 @@ namespace ProductionLineMonitor.Web.Controllers
         private readonly IExcelService _excelService;
 
         public ReportFormController(
-            IReportFormService reportFormService, 
+            IReportFormService reportFormService,
             IOEEService oeeService,
             IExcelService excelService)
         {
@@ -64,11 +64,30 @@ namespace ProductionLineMonitor.Web.Controllers
         public IActionResult GetMachineStatisticV1(string id, DateTime startTime, DateTime endTime)
         {
             //MachineOEE machine = new MachineOEE();
-            List<MachineOEEInfo> lst = _oeeService.GetOEE(id, 
+            List<MachineOEEInfo> lst = _oeeService.GetOEE(id,
                 startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
             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);
+            }
+            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));
+        }
+
         private List<object[]> GetOee(string moduleType, IEnumerable<MachineStatistic> oees)
         {
             var result = new List<object[]>();

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

@@ -36,14 +36,29 @@
                 </div>
             </div>
             <div class="col-md-10">
-                <div class="col-md-12">
+                <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" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")">
+                        <input id="date1" type="text" class="form-control date" value="@DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")">
                         <div class="input-group-addon">-</div>
-                        <input id="date2" type="text" class="form-control" value="@DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")">
+                        <input id="date2" type="text" class="form-control date" value="@DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")">
                     </div>
-                    <div class="col-md-1">
+                    <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-addon">By</div>
+                        <select id="selectMonth" class="form-control" v-on:change="selected()">
+                            <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"
                                     v-on:click="getOEES()">
@@ -109,5 +124,6 @@
     <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="~/lib/ztree.v3/js/jquery.ztree.excheck.min.js"></script>
+    <script src="~/lib/moment.js/moment-with-locales.min.js"></script>
 }
-

+ 519 - 55
ProductionLineMonitor.Web/wwwroot/js/report-form/report-form-v1.js

@@ -3,13 +3,20 @@
     data: {
         dom: Object,
         myChart: Object,
-        option: Object,
+        option_1: Object,
+        option_2: Object,
 
-        oees: [],
+        oees_1: [],
+        oees_2: [],
+        mode: 1,//1为正常,2为chamber汇总
         outputInfo: '',
         outputs: [],
+        ChamberList: [],
+        CheckedChamber: [],
 
         zTreeObj: Object,
+        MutiSelectzTreeObj: Object
+
     },
     mounted() {
         this.init()
@@ -17,13 +24,16 @@
     },
     methods: {
         init() {
+
+            $("#devicechoose").hide();
+            $("#methodchoose").hide();
             this.outputs = [
                 {
 
                 }
             ];
 
-            $(".form-control").datepicker({
+            $(".date").datepicker({
                 format: 'yyyy-mm-dd',
                 language: 'zh-CN',
                 autoclose: true,
@@ -34,12 +44,15 @@
                 return false;
             });
 
+            //zTreeObj = $.fn.zTree.init($("#treeDemo"), settings, res); //初始化树
+            //zTreeObj.expandAll(true);   //true 节点全部展开、false节点收缩
+
             this.dom = document.getElementById('container1');
             this.myChart = echarts.init(this.dom, 'vintage', {
                 renderer: 'canvas',
                 useDirtyRect: false
             });
-            this.option = {
+            this.option_1 = {
                 grid: {
                     left: '4%',
                     right: '10%',
@@ -70,7 +83,7 @@
                         borderColor: "white",
                     },
                 },
-                color: ['#5b9bd5', '#ed7d31', '#a5a5a5','#008080', '#546fc6'],
+                color: ['#5b9bd5', '#ed7d31', '#a5a5a5', '#008080', '#546fc6'],
                 xAxis: {
                     type: 'category',
                     data: [],
@@ -200,87 +213,474 @@
                     }
                 ]
             };
-            this.myChart.on('click', (params) => this.getOutputs(params));
-            if (this.option && typeof option === 'object') {
-                this.myChart.setOption(this.option);
+            this.option_2 = {
+                grid: {
+                    left: '4%',
+                    right: '10%',
+                },
+                tooltip: {
+                    trigger: 'axis',
+                    position: function (point, params, dom, rect, size) {
+                        // 当前鼠标位置
+                        var pointX = point[0];
+                        var pointY = point[1];
+                        return [pointX + 20, pointY + 20];
+                    },
+                    axisPointer: {
+                        type: 'cross',
+                        crossStyle: {
+                            color: '#999'
+                        }
+                    },
+                    formatter: params => {
+                        // 获取xAxis data中的数据
+                        let dataStr = `<div><p style="font-weight:bold;margin:0 8px 15px;">${params[0].name}</p></div>`
+                        var num = 0;
+                        params.forEach(item => {
+                            var str = "";
+                            if (item.seriesName != "平均稼动率") {
+                                str = this.CheckedChamber[parseInt(num / 3)].name + "  ";
+                            }
+                            dataStr += `<div>
+                            <div style="margin: 0 8px;">
+                            <span style="display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:${item.color};"></span>
+                            <span>${str + item.seriesName}</span >
+                            <span style="float:right;color:#000000;margin-left:20px;">${item.data}</span>
+                            </div></div>`;
+                            num++;
+                        })
+                        return dataStr
+                    }
+                },
+                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();
+                            }
+                        }
+                    },
+                    iconStyle: {
+                        borderColor: "white",
+                    },
+                },
+                color: ['#5b9bd5', '#ed7d31', '#a5a5a5', '#008080', '#546fc6'],
+                xAxis: {
+                    type: 'category',
+                    data: [],
+                    axisLabel: {
+                        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} %'
+                        },
+                        splitLine: {
+                            show: false, // 是否显示轴线
+                            lineStyle: {
+                                color: '#e0e6f1', // 刻度线的颜色
+                                width: 1, // 刻度线的宽度
+                                type: 'dashed' // 刻度线的类型
+                            }
+                        }
+                    }
+                ],
+                legend: {
+                    data: ['稼动率', '待机率', '报警率', '平均稼动率'],
+                    textStyle: {
+                        color: 'white',
+                        fontSize: 14
+                    }
+                },
+                series: [
+                ]
+            };
+            if (this.mode == 1) {
+                this.myChart.on('click', (params) => this.getOutputs(params));
+                if (this.option_1 && typeof option_1 === 'object') {
+                    this.myChart.setOption(this.option_1);
+                }
+            }
+            else {
+                this.myChart.on('click', (params) => this.getOutputs(params));
+                if (this.option_2 && typeof option_2 === 'object') {
+                    this.myChart.setOption(this.option_2);
+                }
             }
             window.addEventListener('resize', this.myChart.resize);
         },
         getOutputs(params) {
             if (params.componentType === 'series') {
-                var oee = this.oees[params.dataIndex];
-                this.outputInfo = oee.date + ' ' + oee.shift;
-                this.outputs = [];
-                this.outputs = oee.outPutPerHours;
-                console.log(this.outputs);
+                var oee;
+                if (this.mode == 1) {
+                    oee = this.oees_1[params.dataIndex];
+                    this.outputInfo = oee.date + ' ' + oee.shift;
+                    this.outputs = [];
+                    this.outputs = oee.outPutPerHours;
+                    var htmlstr = '<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>';
+                    for (var item in this.outputs) {
+                        htmlstr = htmlstr + '<tbody><tr>'
+                            + '<td>' + this.outputs[item].period + '</td>'
+                            + '<td>' + this.outputs[item].moduleType + '</td>'
+                            + '<td>' + Math.round(this.outputs[item].autoRunTime / 60 * 10) / 10 + '</td>'
+                            + '<td>' + Math.round(this.outputs[item].alarmTime / 60 * 10) / 10 + '</td>'
+                            + '<td>' + Math.round(this.outputs[item].idleTime / 60 * 10) / 10 + '</td>'
+                            + '<td>' + Math.round(this.outputs[item].loadMATTime / 60 * 10) / 10 + '</td>'
+                            + '<td>' + this.outputs[item].outPut + '</td>'
+                            + '<td>' + this.outputs[item].tt + '</td>'
+                            + '<td>' + this.outputs[item].alarmSum + '</td>'
+                            + '</tr></tbody>';
+                    }
+                    $("#data").html(htmlstr);
+                }
+                else {
+                    var num = 0;
+                    for (var item in this.oees_2) {
+                        if (num == parseInt(params.componentIndex / 3)) {
+                            oee = this.oees_2[item][params.dataIndex];
+                            this.outputs = [];
+                            this.outputs = oee.outPutPerHours;
+                            break;
+                        }
+                        num++;
+                    }
+
+                    this.outputInfo = oee.date;
+                    var htmlstr = '<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>'
+                    if ($("#selectMonth").val() == 1) {
+                        for (var item in this.outputs) {
+                            htmlstr = htmlstr + '<tbody><tr>'
+                                + '<td>' + this.outputs[item].period + '</td>'
+                                + '<td>' + this.outputs[item].moduleType + '</td>'
+                                + '<td>' + Math.round(this.outputs[item].autoRunTime / 60 * 10) / 10 + '</td>'
+                                + '<td>' + Math.round(this.outputs[item].alarmTime / 60 * 10) / 10 + '</td>'
+                                + '<td>' + Math.round(this.outputs[item].idleTime / 60 * 10) / 10 + '</td>'
+                                + '</tr></tbody>';
+                        }
+                    }
+                    else {
+                        for (var item in this.outputs) {
+                            var datetime = moment(this.outputs[item].dataTime);
+                            htmlstr = htmlstr + '<tbody><tr>'
+                                + '<td>' + datetime.format('YYYY-MM-DD') + '</td>'
+                                + '<td>' + this.outputs[item].moduleType + '</td>'
+                                + '<td>' + Math.round(this.outputs[item].autoRunTime / 60 * 10) / 10 + '</td>'
+                                + '<td>' + Math.round(this.outputs[item].alarmTime / 60 * 10) / 10 + '</td>'
+                                + '<td>' + Math.round(this.outputs[item].idleTime / 60 * 10) / 10 + '</td>'
+                                + '</tr></tbody>';
+                        }
+                    }
+                    $("#data").html(htmlstr);
+                }
             }
         },
         getProductionLineMachineTree() {
+            let _this = this;
             var setting = {
                 view: {
                     showIcon: false
+                },
+                callback: {
+                    onClick: function (event, treeId, treeNode) {
+                        if (treeNode.name == "Chamber汇总") {
+                            $("#devicechoose").show();
+                            $("#methodchoose").show();
+                            _this.selected();
+                        }
+                        else {
+                            $("#devicechoose").hide();
+                            $("#methodchoose").hide();
+                            $(".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 = new Date(new Date().setDate(new Date().getDate() - 7));
+                            var date2 = new Date(new Date().setDate(new Date().getDate() - 1));
+                            //$("#date1").val(date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate());
+                            //$("#date2").val(date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate());
+                            var date1_1 = moment(date1);
+                            var date2_1 = moment(date2);
+                            $("#date1").val(date1_1.format('YYYY-MM-DD'));
+                            $("#date2").val(date2_1.format('YYYY-MM-DD'));
+                        }
+                    }
                 }
             };
+            ///下拉框
+            var setting1 = {
+                check: {
+                    enable: true,
+                    nocheckInherit: true,
+                    chkboxType: { "Y": "ps", "N": "ps" }
+                },
+                callback: {
+                    onCheck: function (event, treeId, treeNode) {
+                        var checkedchamberlist = MutiSelectzTreeObj.getCheckedNodes();
+                        _this.CheckedChamber = [];
+                        $("#mutiSelect").val("");
+                        var chambername = [];
+                        for (x in checkedchamberlist) {
+                            if (checkedchamberlist[x].name != "H5 Chamber") {
+                                chambername.push(checkedchamberlist[x].name);
+                                _this.CheckedChamber.push(checkedchamberlist[x]);
+                            }
+                        }
+                        $("#mutiSelect").val(chambername.join(','));
+                    }
+                }
+            }
             $.ajax({
                 url: '/ProductionLine/GetProductionLineMachineTree',
                 type: 'GET',
                 async: true,
                 success: function (zNodes) {
                     zTreeObj = $.fn.zTree.init($('#productionLineTree'), setting, zNodes);
+                    for (var node in zNodes) {
+                        if (node.name = "H5 Chamber") {
+                            _this.ChamberList = [zNodes[node]];
+                        }
+                    }
+                    _this.ChamberList[0].children.splice(0, 1);
+                    MutiSelectzTreeObj = $.fn.zTree.init($('#treeDemo'), setting1, _this.ChamberList);
+                    MutiSelectzTreeObj.expandAll(true);
+
                 }
             });
+
         },
         getOEES() {
+            if ($("#menuContent").css("display") == "block") {
+                $("#menuContent").css("display", "none");
+            }
+
+            let _this = this
             var nodes = zTreeObj.getSelectedNodes()[0];
             if (nodes == null) {
                 alert("请选择设备!");
                 return;
             }
+            if (nodes.name == "Chamber汇总") {
+                this.mode = 2;
+                $("#devicechoose").show();
+                $("#methodchoose").show();
+                var idsStr = [];
+                for (var item in _this.CheckedChamber) {
+                    idsStr.push(_this.CheckedChamber[item].id);
+                }
+                idsStr = idsStr.toString();
+                if (idsStr == null || idsStr == "") {
+                    alert("请选择设备!");
+                    return;
+                }
+                if ($("#selectMonth").val() == 1 && Math.floor(Math.abs(Date.parse($("#date2").val()) - Date.parse($("#date1").val())) / (1000 * 3600 * 24)) > 7) {
+                    alert("按天统计时,不可超过7日!!");
+                    return;
+                }
+                $.ajax({
+                    url: '/ReportForm/GetMachineStatisticV2',
+                    type: 'POST',
+                    async: true,
+                    data: {
+                        "id": idsStr.toString(),
+                        "startTime": $("#date1").val(),
+                        "endTime": $("#date2").val(),
+                        "peroid": $("#selectMonth").val()
+                    },
+                    success: function (rev) {
+                        if (rev.code === 0) {
+                            _this.oees_2 = rev.data;
+                            var xData = [];
+                            _this.option_2.series = [];
+                            var chambernum = 0;
+                            var avgrunrate = [];
+                            for (var i in rev.data) {
+                                var chamber_name = "";
+                                for (var j in _this.CheckedChamber) {
+                                    if (_this.CheckedChamber[j].id == i) {
+                                        chamber_name = _this.CheckedChamber[j].name;
+                                        break;
+                                    }
+                                }
+                                var seriestemp1 = {
+                                    type: 'value',
+                                    name: '稼动率',
+                                    data: [],
+                                    type: 'bar',
+                                    stack: chamber_name,
+                                    label: {
+                                        show: true,
+                                        color: 'white',
+                                        fontSize: 12
+                                    }
+                                }
+                                var seriestemp2 = {
+                                    type: 'value',
+                                    name: '待机率',
+                                    data: [],
+                                    type: 'bar',
+                                    stack: chamber_name,
+                                    label: {
+                                        show: true,
+                                        color: 'white',
+                                        fontSize: 12
+                                    },
+                                };
+                                var seriestemp3 =
+                                {
+                                    type: 'value',
+                                    name: '报警率',
+                                    data: [],
+                                    type: 'bar',
+                                    stack: chamber_name,
+                                    label: {
+                                        show: true,
+                                        color: 'white',
+                                        fontSize: 12
+                                    },
+                                };
 
-            let _this = this
+                                for (var k in rev.data[i]) {
+                                    if (chambernum == 0) {
+                                        xData.push(rev.data[i][k].date);
+                                        avgrunrate.push(rev.data[i][k].runTimeRate);
+                                    }
+                                    else {
+                                        avgrunrate[k] += rev.data[i][k].runTimeRate;
+                                    }
+                                    seriestemp1.data.push(rev.data[i][k].runTimeRate.toFixed(1));
+                                    seriestemp2.data.push(rev.data[i][k].idelTimeRate.toFixed(1));
+                                    seriestemp3.data.push(rev.data[i][k].downTimeRate.toFixed(1));
+                                }
 
-            $.ajax({
-                url: '/ReportForm/GetMachineStatisticV1',
-                type: 'POST',
-                async: true,
-                data: {
-                    "id": nodes.id,
-                    "startTime": $("#date1").val(),
-                    "endTime": $("#date2").val()
-                },
-                success: function (rev) {
-                    if (rev.code === 0) {
-                        _this.oees = rev.data;
-
-                        console.log(rev.data);
-                        var xData = [];
-                        var yDataProductA = [];
-                        var yDataProductB = [];
-                        var yDataProductC = [];
-                        var yDataProductD = [];
-                        var yDataProductE = [];
-
-                        for (var i = 0; i < rev.data.length; i++) {
-                            xData.push(rev.data[i].date + ' ' + rev.data[i].shift);
-                            yDataProductA.push(rev.data[i].outputs);
-                            yDataProductB.push(rev.data[i].runTimeRate);
-                            yDataProductC.push(rev.data[i].idelTimeRate);
-                            yDataProductD.push(rev.data[i].downTimeRate);
-                            yDataProductE.push(rev.data[i].loadMATTimeRate);
+                                _this.option_2.series.push(seriestemp1);
+                                _this.option_2.series.push(seriestemp2);
+                                _this.option_2.series.push(seriestemp3);
+
+                                chambernum++;
+                            }
+                            for (var item in avgrunrate) {
+                                avgrunrate[item] = (avgrunrate[item] / chambernum).toFixed(1);
+                            }
+                            _this.option_2.series.push({
+                                type: 'value',
+                                name: '平均稼动率',
+                                data: avgrunrate,
+                                type: 'line',
+                                label: {
+                                    show: true,
+                                    color: 'white',
+                                    fontSize: 12
+                                }
+                            })
+                            _this.option_2.xAxis.data = xData;
+                            _this.myChart.clear();
+                            _this.myChart.setOption(_this.option_2, true);//true重绘
+
+                        } else {
+                            alert(rev.message);
                         }
+                    }
+                });
+            }
+            else {
+                this.mode = 1;
+                $("#devicechoose").hide();
+                $("#methodchoose").hide();
+                $.ajax({
+                    url: '/ReportForm/GetMachineStatisticV1',
+                    type: 'POST',
+                    async: true,
+                    data: {
+                        "id": nodes.id,
+                        "startTime": $("#date1").val(),
+                        "endTime": $("#date2").val()
+                    },
+                    success: function (rev) {
+                        if (rev.code === 0) {
+                            _this.oees_1 = rev.data;
+                            var xData = [];
+                            var yDataProductA = [];
+                            var yDataProductB = [];
+                            var yDataProductC = [];
+                            var yDataProductD = [];
+                            var yDataProductE = [];
 
-                        _this.option.xAxis.data = xData;
-                        _this.option.series[0].data = yDataProductB;
-                        _this.option.series[1].data = yDataProductC;
-                        _this.option.series[2].data = yDataProductD;
-                        _this.option.series[3].data = yDataProductE;
-                        _this.option.series[4].data = yDataProductA;
-                        _this.myChart.setOption(_this.option);
-                    } else {
-                        alert(rev.message);
+                            for (var i = 0; i < rev.data.length; i++) {
+                                xData.push(rev.data[i].date + ' ' + rev.data[i].shift);
+                                yDataProductA.push(rev.data[i].outputs);
+                                yDataProductB.push(rev.data[i].runTimeRate);
+                                yDataProductC.push(rev.data[i].idelTimeRate);
+                                yDataProductD.push(rev.data[i].downTimeRate);
+                                yDataProductE.push(rev.data[i].loadMATTimeRate);
+                            }
+
+                            _this.option_1.xAxis.data = xData;
+                            _this.option_1.series[0].data = yDataProductB;
+                            _this.option_1.series[1].data = yDataProductC;
+                            _this.option_1.series[2].data = yDataProductD;
+                            _this.option_1.series[3].data = yDataProductE;
+                            _this.option_1.series[4].data = yDataProductA;
+
+
+                            _this.myChart.clear();
+                            _this.myChart.setOption(_this.option_1, true);//true重绘
+                        } else {
+                            alert(rev.message);
+                        }
                     }
-                }
-            });
+                });
+            }
         },
         exportExcelTemplate() {
             var sheetName = 'sheet1';
@@ -291,7 +691,7 @@
 
             var sheet = {};
 
-            sheet['!ref'] = 'A1:' + 'K' + (this.oees.length + 1);
+            sheet['!ref'] = 'A1:' + 'K' + (this.oees_1.length + 1);
             sheet['!cols'] = [
                 { wch: 10 },
                 { wch: 12 },
@@ -318,7 +718,7 @@
             sheet['J1'] = { t: "s", v: "报警率(%)" };
             sheet['K1'] = { t: "s", v: "换料率(%)" };
 
-            this.oees.forEach(function (row, i) {
+            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 };
@@ -367,6 +767,70 @@
                 event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
             }
             aLink.dispatchEvent(event);
+        },
+        showMenu() {
+            if ($("#menuContent").css("display") == "block") {
+                $("#menuContent").css("display", "none");
+                return;
+            }
+            else {
+                $("#menuContent").css("display", "block");
+                $("#menuContent").css("left", $('#mutiSelect').offset().left - $('#form1').offset().left + "px");
+                $("#menuContent").css("top", $('#devicechoose').height() + "px");
+            }
+        },
+        selected() {
+            var v = $("#selectMonth").val();
+            if (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 = new Date(new Date().setDate(new Date().getDate() - 7));
+                var date2 = new Date(new Date().setDate(new Date().getDate() - 1));
+                var date1_1 = moment(date1);
+                var date2_1 = moment(date2);
+                //$("#date1").val(date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate());
+                //$("#date2").val(date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate());
+                $("#date1").val(date1_1.format('YYYY-MM-DD'));
+                $("#date2").val(date2_1.format('YYYY-MM-DD'));
+                console.log(date1_1.format('YYYY-MM'));
+                console.log(date2_1.format('YYYY-MM'));
+            }
+            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() - 7));
+                var date2 = new Date(new Date().setDate(new Date().getDate() - 1));
+                //$("#date1").val(date1.getFullYear() + "-" + (date1.getMonth() + 1));
+                //$("#date2").val(date2.getFullYear() + "-" + (date2.getMonth() + 1));
+                var date1_1 = moment(date1);
+                var date2_1 = moment(date2);
+                //$("#date1").val(date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate());
+                //$("#date2").val(date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate());
+                $("#date1").val(date1_1.format('YYYY-MM'));
+                $("#date2").val(date2_1.format('YYYY-MM'));
+                console.log(date1_1.format('YYYY-MM'));
+                console.log(date2_1.format('YYYY-MM'));
+            }
         }
     },
     filters: {

+ 1 - 0
ProductionLineMonitor.WebAPI/HostMqttClient.cs

@@ -3,6 +3,7 @@ using HslCommunication.LogNet;
 using HslCommunication.MQTT;
 using Microsoft.EntityFrameworkCore;
 using NPOI.SS.Formula.Functions;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using ProductionLineMonitor.Application.Services.CimService;
 using ProductionLineMonitor.Core.Dtos;
 using ProductionLineMonitor.Core.Services;

+ 2 - 2
ProductionLineMonitor.WebAPI/appsettings.json

@@ -11,8 +11,8 @@
   },
   "MqttOptions": {
     "IpAddress": "127.0.0.1",
-    "Port": 1885,
+    "Port": 1883,
     "ClientId": "HostProductionLineMonitorWebAPI"
   },
-  "urls": "http://*:80;"
+  "urls": "http://*:5001;"
 }