using log4net;
using Microsoft.AspNetCore.Mvc;
using Ropin.Inspection.Api.Common;
using Ropin.Inspection.Model.ViewModel;
using Ropin.Inspection.Service.LGS.Interface;
using System.Threading.Tasks;
using System;
using Ropin.Inspection.Service;
using Ropin.Inspection.Service.Interface;
using Ropin.Inspection.Model.ViewModel.LGS;
using System.Collections.Generic;
using System.Linq;
using Ropin.Inspection.Model.SearchModel.LGS;
using Castle.Core.Internal;
using Ropin.Inspection.Model.Common;
using NPOI.SS.Formula.Functions;
using Ropin.Inspection.Service.MTN.Interface;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
namespace Ropin.Inspection.Api.Controllers.LGS
{
public class ScreenInterfaceDataController : BaseController
{
private readonly ILGSLargeScreenService _lGSLargeScreenService;
private readonly ITmtnDevOpsService _TmtnDevOpsService;
private readonly ITmtnRepairOrderService _TmtnRepairOrderService;
private readonly ITispRecordService _tispRecordService;
private readonly ITmtnAlarmOrderService _tmtnAlarmOrderService;
private static readonly ILog log = LogManager.GetLogger(typeof(ScreenInterfaceDataController));
///
/// 构造函数
///
public ScreenInterfaceDataController(ILGSLargeScreenService lGSLargeScreenService, ITmtnDevOpsService TmtnDevOpsService, ITmtnRepairOrderService tmtnRepairOrderService, ITispRecordService tispRecordService, ITmtnAlarmOrderService tmtnAlarmOrderService)
{
_lGSLargeScreenService = lGSLargeScreenService;
_TmtnDevOpsService = TmtnDevOpsService;
_TmtnRepairOrderService = tmtnRepairOrderService;
_tispRecordService = tispRecordService;
_tmtnAlarmOrderService = tmtnAlarmOrderService;
}
///
/// 设备维保-柱状图统计[天]
///
///
///
[HttpPost("DevOpsDaysStatisticsBarChart")]
public async Task DevOpsDaysStatisticsBarChart(LargeScreenInterfaceDataSearch search)
{
if (search == null || string.IsNullOrEmpty(search.DevCode))
{
return new ApiResult(ReturnCode.GeneralError);
}
try
{
IEnumerable content = await _lGSLargeScreenService.DevOpsDaysStatistics(search.DevCode, search.Days);
if (content != null && content.Count() > 0)
{
List YData= new List();
//normal=4、abnormal=3
//【approval=1;confirm=2;repairOn=3;complete=4;cancel=5;repairRework=6;repairCompleted=7】
switch (search.DataType)
{
case "approval":
case "1":
YData = content.Select(d => d.Status1.ToString()).ToList();break;
case "confirm":
case "2":
YData = content.Select(d => d.Status2.ToString()).ToList(); break;
case "repairOn":
case "abnormal":
case "3":
YData = content.Select(d => d.Status3.ToString()).ToList(); break;
case "complete":
case "normal":
case "4":
YData = content.Select(d => d.Status4.ToString()).ToList(); break;
case "cancel":
case "5":
YData = content.Select(d => d.Status5.ToString()).ToList(); break;
case "repairRework":
case "6":
YData = content.Select(d => d.Status6.ToString()).ToList(); break;
case "repairCompleted":
case "7":
YData = content.Select(d => d.Status7.ToString()).ToList(); break;
default:
YData = content.Select(d => d.StatusTotal.ToString()).ToList(); break;
}
var data = new
{
y = YData,
x = content.Select(d => d.SpecificDay).ToArray()
};
return new ApiResult