using Cksoft.Data; using Cksoft.Data.Repository; using Cksoft.Unity; using DllEapDal.RA; using DllEapEntity.Dtos; using DllEapEntity.OFILM; using DllEapEntity.RA; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using ChartDto = DllEapEntity.OFILM.ChartDto; namespace DllEapBll.RA { /// /// RA实验室数据看板 /// [Route("eap/api/[controller]/[action]")] [ApiController] [Authorize] public class DataBoardController : ControllerBase { [HttpGet] public LayuiModel> Get(DateTime? time, string fcode, string factory, string status,string fname) { using (IDatabase db = DbFactory.Base("RA")) { var dal = new DataBoardDal(db); //Dictionary da =new Dictionary(); var da = new List>(); double ds = 0; DateTime date; if (!time.HasValue) { date = DateTime.Now; } else { date = time.Value; } IEnumerable> data = dal.Get(date, fcode, factory, status, fname, ref da, ref ds); return new LayuiModel>() { code = 1, data = data, extraObject = da }; } } [HttpGet] public List>> GetTemp(DateTime? time, string Fcode) { using (IDatabase db = DbFactory.Base("RA")) { var dal = new DataBoardDal(db); if (!time.HasValue) { time = DateTime.Now; } string start = time.Value.ToString("yyyy-MM-dd 00:00:00"); string end; if (DateTime.Now.Subtract(time.Value).TotalDays < 1) { end = DateTime.Now.AddMinutes(1).ToString("yyyy-MM-dd HH:mm:00"); } else { end = time.Value.AddDays(1).ToString("yyyy-MM-dd 00:00:00"); } return dal.GetTemp(start, end, Fcode); } } [HttpGet] public ChartDto GetAlarm(DateTime? time, string Fcode) { using (IDatabase db = DbFactory.Base("RA")) { var dal = new DataBoardDal(db); var dic = new Dictionary(); return dal.GetAlarm(time, Fcode, ref dic); } } [HttpGet] public LayuiModel GetBase(DateTime? time, string Fcode) { using (IDatabase db = DbFactory.Base("RA")) { var dal = new DataBoardDal(db); return dal.GetBase(time, Fcode); } } [HttpGet] public EapResponse GetStatus(DateTime? time, string Fcode) { using (IDatabase db = DbFactory.Base("RA")) { DateTime date; var res = new EapResponse { Code = 1, Msg = string.Empty }; if (!time.HasValue) { date = DateTime.Now; } else { date = time.Value; } var dal = new DataBoardDal(db); List d = new List(); var datas = dal.GetStatus(date, Fcode, out d); if (datas == null || datas.Count() <= 0) { res.Code = -1; res.Msg = ""; return res; } res.Data = datas; return res; } } [HttpGet] public EapResponse GetStatusRatio(DateTime? time, string Fcode) { using (IDatabase db = DbFactory.Base("RA")) { DateTime date; var res = new EapResponse { Code = 1, Msg = string.Empty }; if (!time.HasValue) { date = DateTime.Now; } else { date = time.Value; } var dal = new DataBoardDal(db); List datas = new List(); dal.GetStatus(date, Fcode, out datas); if (datas == null || datas.Count() <= 0) { res.Code = -1; res.Msg = ""; return res; } res.Data = datas; return res; } } [HttpGet] public LayuiModel GetAlarmDetails(DateTime? time, string Fcode) { using (IDatabase db = DbFactory.Base("RA")) { DateTime date; var res = new LayuiModel { code = 1, msg = string.Empty }; if (!time.HasValue) { date = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); } else { date = time.Value; } var dal = new DataBoardDal(db); var datas = dal.GetAlarmDetails(date, Fcode); if (datas == null || datas.Count() <= 0) { res.code = -1; res.msg = ""; return res; } res.data = datas; return res; } } /// /// /// /// 开始时间 /// 结束时间 /// 设备ID /// /// /// [HttpGet] public LayuiModel GetTempDetail(DateTime? start, DateTime? end,string fcode, int pageIndex = 1, int pageSize = 20) { using (IDatabase db = DbFactory.Base("RA")) { if (string.IsNullOrEmpty(fcode)) { fcode = "GDW0001"; } if (!end.HasValue) { end = DateTime.Now; } end = end.Value > DateTime.Now ? DateTime.Now : end.Value; if (!start.HasValue) { start = Convert.ToDateTime(end.Value.ToString("D")); } var dal = new DataBoardDal(db); return dal.GetTempDetail(start.Value, end.Value, fcode, pageIndex, pageSize); } } } }