public static List <ClusterModel> GetNSCForChart(int lineId, TimeSpan timeStart, TimeSpan timeEnd, string date) { try { var db = new PMSEntities(); var clusters = BLLCluster.GetAllByLineId(lineId); if (clusters != null && clusters.Count > 0) { var ids = clusters.Select(x => x.Id); var tdns = db.TheoDoiNgays.Where(x => !x.Chuyen.IsDeleted && !x.Cum.IsDeleted && x.Date == date && x.MaChuyen == lineId && ids.Contains(x.CumId)).ToList(); foreach (var item in clusters) { var tang = tdns.Where(x => x.CumId == item.Id && x.Time >= timeStart && x.Time <= timeEnd && x.CommandTypeId == (int)eCommandRecive.ProductIncrease && x.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(x => x.ThanhPham); var giam = tdns.Where(x => x.CumId == item.Id && x.Time >= timeStart && x.Time <= timeEnd && x.CommandTypeId == (int)eCommandRecive.ProductReduce && x.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(x => x.ThanhPham); tang = tang - giam; item.KCS = tang > 0 ? tang : 0; } return(clusters); } } catch (Exception ex) { } return(null); }
public static List <KeypadModel> GetKeyPadInfoByLineId(int maChuyen) { try { var db = new PMSEntities(); var clusters = BLLCluster.GetAllByLineId(maChuyen); if (clusters != null && clusters.Count > 0) { var ids = clusters.Select(x => x.Id); return(db.KeyPad_Object.Where(x => !x.IsDeleted && !x.KeyPad.IsDeleted && !x.Cum.IsDeleted && !x.Cum.Chuyen.IsDeleted && ids.Contains(x.ClusterId)).Select(x => new KeypadModel() { Id = x.KeyPadId, sttNut = x.STTNut, EquipmentId = x.KeyPad.EquipmentId, CommandTypeId = x.CommandTypeId, FloorId = x.KeyPad.FloorId, UseTypeId = x.KeyPad.UseTypeId, LineId = x.Cum.IdChuyen, ClusterId = x.ClusterId, IsEndOfLine = x.Cum.IsEndOfLine, TypeOfKeypad = x.TypeOfKeypad }).ToList()); } } catch (Exception ex) { } return(new List <KeypadModel>()); }