EYZManufacturingPlatformController.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 IProductionLineCoreService _productionLineService;
  20. private readonly IUnitOfWork _unitOfWork;
  21. public EYZManufacturingPlatformController(
  22. IReportFormService reportFormService,
  23. IOEEService oeeService,
  24. IExcelService excelService,
  25. IProductionLineCoreService productionLineService,
  26. IUnitOfWork unitOfWork)
  27. {
  28. _reportFormService = reportFormService;
  29. _oeeService = oeeService;
  30. _excelService = excelService;
  31. _productionLineService = productionLineService;
  32. _unitOfWork = unitOfWork;
  33. }
  34. [HttpGet]
  35. public IActionResult Y5OEE()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. ///
  41. /// </summary>
  42. /// <param name="id"></param>
  43. /// <param name="startTime"></param>
  44. /// <param name="endTime"></param>
  45. /// <param name="peroid"></param>//0:按班;1:天;2:周;3:月
  46. /// <param name="dayOrnight"></param>//peroid为0时有效,0:汇总,1:白班数据,2:夜班数据
  47. /// <returns></returns>
  48. [HttpPost]
  49. public IActionResult GetMachineStatisticV4(string id, DateTime startTime, DateTime endTime, int peroid, int dayOrnight)
  50. {
  51. var list = _oeeService.GetOEEByPeriod(id, startTime, endTime, peroid, dayOrnight);
  52. return Ok(ResultDto<Dictionary<string, List<MachineOEEInfoByPeriod>>>.Success(list));
  53. }
  54. [HttpPost]
  55. public IActionResult GetOEEExtendSetting(string ids)
  56. {
  57. var idList = ids.Split(',');
  58. var machine = _unitOfWork.Repository<Machine>().GetList().Where(x => idList.Contains(x.Id));
  59. Dictionary<string, string> DicOEEExtend = new Dictionary<string, string>();
  60. if (machine != null && machine.Count() != 0)
  61. {
  62. foreach (var item in machine)
  63. {
  64. DicOEEExtend.Add(item.Id, string.IsNullOrEmpty(item.OEEExtendSettings) ? "" : item.OEEExtendSettings);
  65. }
  66. }
  67. return Ok(ResultDto<Dictionary<string, string>>.Success(DicOEEExtend));
  68. }
  69. /// <summary>
  70. ///带汇总
  71. /// </summary>
  72. /// <returns></returns>
  73. [HttpGet]
  74. public IActionResult GetProductionLineMachineTreeV1()
  75. {
  76. return Ok(_productionLineService.GetProductionLineMachineTreeV1().Nodes);
  77. }
  78. }
  79. }