EYZManufacturingPlatformController.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Microsoft.AspNetCore.Mvc;
  2. using ProductionLineMonitor.Application.Services.OEEService.Dtos;
  3. using System.Collections.Generic;
  4. using System;
  5. using ProductionLineMonitor.Application.Services.OEEService;
  6. using ProductionLineMonitor.Application.Services;
  7. using ProductionLineMonitor.Core.IRepositories;
  8. using ProductionLineMonitor.Core.Services;
  9. using ProductionLineMonitor.Core.Dtos;
  10. using System.Linq;
  11. using ProductionLineMonitor.Core.Models;
  12. namespace ProductionLineMonitor.Web.Controllers
  13. {
  14. public class EYZManufacturingPlatformController : Controller
  15. {
  16. private readonly IReportFormService _reportFormService;
  17. private readonly IOEEService _oeeService;
  18. private readonly IExcelService _excelService;
  19. private readonly IUnitOfWork _unitOfWork;
  20. public EYZManufacturingPlatformController(
  21. IReportFormService reportFormService,
  22. IOEEService oeeService,
  23. IExcelService excelService,
  24. IUnitOfWork unitOfWork)
  25. {
  26. _reportFormService = reportFormService;
  27. _oeeService = oeeService;
  28. _excelService = excelService;
  29. _unitOfWork = unitOfWork;
  30. }
  31. [HttpGet]
  32. public IActionResult Y5OEE()
  33. {
  34. return View();
  35. }
  36. [HttpPost]
  37. public IActionResult GetMachineStatisticV2(string id, DateTime startTime, DateTime endTime, int peroid)
  38. {
  39. //MachineOEE machine = new MachineOEE();
  40. Dictionary<string, List<MachineOEEInfoByPeriod>> lst = new Dictionary<string, List<MachineOEEInfoByPeriod>>();
  41. if (peroid == 3)
  42. {
  43. lst = _oeeService.GetOEEByPeriod(id,
  44. startTime.ToString("yyyy-MM"), endTime.ToString("yyyy-MM"), peroid);
  45. }
  46. else
  47. {
  48. lst = _oeeService.GetOEEByPeriod(id,
  49. startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"), peroid);
  50. }
  51. return Ok(ResultDto<Dictionary<string, List<MachineOEEInfoByPeriod>>>.Success(lst));
  52. }
  53. [HttpPost]
  54. public IActionResult GetMachineStatisticV1(string id, DateTime startTime, DateTime endTime)
  55. {
  56. //MachineOEE machine = new MachineOEE();
  57. List<MachineOEEInfo> lst = _oeeService.GetOEE(id,
  58. startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  59. return Ok(ResultDto<List<MachineOEEInfo>>.Success(lst));
  60. }
  61. [HttpPost]
  62. public IActionResult GetOEEExtendSetting(string id)
  63. {
  64. var machine = _unitOfWork.Repository<Machine>().GetList().Where(x => x.Id == id);
  65. if (machine != null && machine.Count() != 0 && !String.IsNullOrEmpty(machine.First().OEEExtendSettings))
  66. {
  67. return Ok(ResultDto<string>.Success(machine.First().OEEExtendSettings));
  68. }
  69. else
  70. {
  71. return Ok(ResultDto<string>.Success(""));
  72. }
  73. }
  74. }
  75. }