using Microsoft.AspNetCore.Mvc; using ProductionLineMonitor.Application.Services.OEEService.Dtos; using System.Collections.Generic; using System; using ProductionLineMonitor.Application.Services.OEEService; using ProductionLineMonitor.Application.Services; using ProductionLineMonitor.Core.IRepositories; using ProductionLineMonitor.Core.Services; using ProductionLineMonitor.Core.Dtos; using System.Linq; using ProductionLineMonitor.Core.Models; namespace ProductionLineMonitor.Web.Controllers { public class EYZManufacturingPlatformController : Controller { private readonly IReportFormService _reportFormService; private readonly IOEEService _oeeService; private readonly IExcelService _excelService; private readonly IUnitOfWork _unitOfWork; public EYZManufacturingPlatformController( IReportFormService reportFormService, IOEEService oeeService, IExcelService excelService, IUnitOfWork unitOfWork) { _reportFormService = reportFormService; _oeeService = oeeService; _excelService = excelService; _unitOfWork = unitOfWork; } [HttpGet] public IActionResult Y5OEE() { return View(); } [HttpPost] public IActionResult GetMachineStatisticV2(string id, DateTime startTime, DateTime endTime, int peroid) { //MachineOEE machine = new MachineOEE(); Dictionary> lst = new Dictionary>(); 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>>.Success(lst)); } [HttpPost] public IActionResult GetMachineStatisticV1(string id, DateTime startTime, DateTime endTime) { //MachineOEE machine = new MachineOEE(); List lst = _oeeService.GetOEE(id, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd")); return Ok(ResultDto>.Success(lst)); } [HttpPost] public IActionResult GetOEEExtendSetting(string id) { var machine = _unitOfWork.Repository().GetList().Where(x => x.Id == id); if (machine != null && machine.Count() != 0 && !String.IsNullOrEmpty(machine.First().OEEExtendSettings)) { return Ok(ResultDto.Success(machine.First().OEEExtendSettings)); } else { return Ok(ResultDto.Success("")); } } } }