From 591be7e1d2ef59c2c24aabe6d3b30193e16fbef4 Mon Sep 17 00:00:00 2001 From: wyw <571921741@qq.com> Date: Wed, 5 Jun 2024 15:06:00 +0800 Subject: [PATCH] 56 --- .../Api/BIController/BIHomeController.cs | 168 +++++++++--------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIHomeController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIHomeController.cs index 9b233b1..8a8526f 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIHomeController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIHomeController.cs @@ -887,112 +887,112 @@ namespace APT.SC.WebApi.Controllers.Api.BI //按生产单元 获取 - if (!string.IsNullOrEmpty(filter.Keyword)) + //if (!string.IsNullOrEmpty(filter.Keyword)) + //{ + //int MineType = int.Parse(filter.Keyword.ToString()); + //BaseFilter filterD = new BaseFilter(); + //filterD.SelectField = new List { "ID", "NAME", "DEPARTMENT_TYPE", "PARENT_ID" }; + + //var listDep1MineType = GetEntities(t => t.MineType.HasValue && t.MineType == MineType && t.DEPARTMENT_TYPE == 0, filterD, null);//部门就可以了 因为都相向 统计了 + if (listDep != null && listDep.Any()) { - //int MineType = int.Parse(filter.Keyword.ToString()); - //BaseFilter filterD = new BaseFilter(); - //filterD.SelectField = new List { "ID", "NAME", "DEPARTMENT_TYPE", "PARENT_ID" }; + List ListSafeCheckYearMonth = new List(); + int befoMonth = 12; + List ListSafeCheckYearMonthT = BIHomeService.GetHomeCheckCountMonth(filter.OrgId, listDep.ToList(), befoMonth).ToList(); + var listCheckTypeIDT = ListSafeCheckYearMonthT.Select(e => e.SOURCEID).Distinct().ToList(); - //var listDep1MineType = GetEntities(t => t.MineType.HasValue && t.MineType == MineType && t.DEPARTMENT_TYPE == 0, filterD, null);//部门就可以了 因为都相向 统计了 - if (listDep != null && listDep.Any()) + //var enums = GetEntity(e => e.VALUE == MineType && e.CODE == "BSMineTypeEnum"); + //if (enums != null) + //{ + //var listTypeMine = GetEntities(e => e.MINETYPE_ENUMS_ID == enums.ID, null, null); + var listTypeMine = GetEntities(e => 1 == 1, null, null); + if (listTypeMine != null && listTypeMine.Any()) { - List ListSafeCheckYearMonth = new List(); - int befoMonth = 12; - List ListSafeCheckYearMonthT = BIHomeService.GetHomeCheckCountMonth(filter.OrgId, listDep.ToList(), befoMonth).ToList(); - var listCheckTypeIDT = ListSafeCheckYearMonthT.Select(e => e.SOURCEID).Distinct().ToList(); - - //var enums = GetEntity(e => e.VALUE == MineType && e.CODE == "BSMineTypeEnum"); - //if (enums != null) - //{ - //var listTypeMine = GetEntities(e => e.MINETYPE_ENUMS_ID == enums.ID, null, null); - var listTypeMine = GetEntities(e => 1 == 1, null, null); - if (listTypeMine != null && listTypeMine.Any()) + var listMineCheckTypeID = listTypeMine.Where(e => e.CHECK_TYPE_ID.HasValue).Select(e => e.CHECK_TYPE_ID.Value); + for (int i = 0; i < listCheckTypeIDT.Count; i++) { - var listMineCheckTypeID = listTypeMine.Where(e => e.CHECK_TYPE_ID.HasValue).Select(e => e.CHECK_TYPE_ID.Value); - for (int i = 0; i < listCheckTypeIDT.Count; i++) + if (!listMineCheckTypeID.Contains(listCheckTypeIDT[i])) { - if (!listMineCheckTypeID.Contains(listCheckTypeIDT[i])) - { - listCheckTypeIDT.RemoveAt(i); - i--; - } + listCheckTypeIDT.RemoveAt(i); + i--; } } - //} + } + //} - var listCheckType = GetEntities(e => listCheckTypeIDT.Contains(e.ID), null, null).OrderBy(e => e.PARENT_ID).ThenBy(e => e.NUM).ToList(); + var listCheckType = GetEntities(e => listCheckTypeIDT.Contains(e.ID), null, null).OrderBy(e => e.PARENT_ID).ThenBy(e => e.NUM).ToList(); - List listCheckTypeID = new List(); - List listCheckTypeNAME = new List(); + List listCheckTypeID = new List(); + List listCheckTypeNAME = new List(); - Guid IDZH = Guid.Empty;//综合检查(只有一个) - List listGUID = new List();//综合检查子集 - for (int i = 0; i < listCheckType.Count; i++) + Guid IDZH = Guid.Empty;//综合检查(只有一个) + List listGUID = new List();//综合检查子集 + for (int i = 0; i < listCheckType.Count; i++) + { + if (listCheckType[i].PARENT_ID.HasValue) { - if (listCheckType[i].PARENT_ID.HasValue) + if (IDZH == Guid.Empty) { - if (IDZH == Guid.Empty) - { - IDZH = listCheckType[i].PARENT_ID.Value; - listCheckTypeID.Add(IDZH); - var checkTypeP = GetEntity(IDZH); - listCheckTypeNAME.Add(checkTypeP.NAME); - } - listGUID.Add(listCheckType[i].ID); + IDZH = listCheckType[i].PARENT_ID.Value; + listCheckTypeID.Add(IDZH); + var checkTypeP = GetEntity(IDZH); + listCheckTypeNAME.Add(checkTypeP.NAME); + } + listGUID.Add(listCheckType[i].ID); + } + else + { + listCheckTypeID.Add(listCheckType[i].ID); + listCheckTypeNAME.Add(listCheckType[i].NAME); + } + } + + int year = DateTime.Now.Year; + int Month = DateTime.Now.Month; + DateTime dtTemp = DateTime.Now; + IEnumerable listPerChearch = null; + IEnumerable listPerChearchPer = null; + + //List listListCount = null; + for (int i = 0; i < befoMonth; i++) + { + dtTemp = dtNow.AddMonths(-1 * i); + year = dtTemp.Year; + Month = dtTemp.Month; + listPerChearch = ListSafeCheckYearMonthT.Where(e => e.YEAR == year && e.MONTH == Month); + HomeSafeCheckCountMonth modelper = new HomeSafeCheckCountMonth(); + modelper.Total = listPerChearch.Count(); + modelper.listSOURCENAME = listCheckTypeNAME; + modelper.YEAR = year; + modelper.MONTH = Month; + List listListCount = new List(); + + for (int j = 0; j < listCheckTypeID.Count; j++) + { + if (listCheckTypeID[j] != IDZH) + { + listPerChearchPer = listPerChearch.Where(e => e.YEAR == year && e.MONTH == Month && e.SOURCEID == listCheckTypeID[j]);//各个检查 } else { - listCheckTypeID.Add(listCheckType[i].ID); - listCheckTypeNAME.Add(listCheckType[i].NAME); + listPerChearchPer = listPerChearch.Where(e => e.YEAR == year && e.MONTH == Month && listGUID.Contains(e.SOURCEID));//综合检查 } - } - int year = DateTime.Now.Year; - int Month = DateTime.Now.Month; - DateTime dtTemp = DateTime.Now; - IEnumerable listPerChearch = null; - IEnumerable listPerChearchPer = null; - - //List listListCount = null; - for (int i = 0; i < befoMonth; i++) - { - dtTemp = dtNow.AddMonths(-1 * i); - year = dtTemp.Year; - Month = dtTemp.Month; - listPerChearch = ListSafeCheckYearMonthT.Where(e => e.YEAR == year && e.MONTH == Month); - HomeSafeCheckCountMonth modelper = new HomeSafeCheckCountMonth(); - modelper.Total = listPerChearch.Count(); - modelper.listSOURCENAME = listCheckTypeNAME; - modelper.YEAR = year; - modelper.MONTH = Month; - List listListCount = new List(); - - for (int j = 0; j < listCheckTypeID.Count; j++) + if (listPerChearchPer == null || !listPerChearchPer.Any()) { - if (listCheckTypeID[j] != IDZH) - { - listPerChearchPer = listPerChearch.Where(e => e.YEAR == year && e.MONTH == Month && e.SOURCEID == listCheckTypeID[j]);//各个检查 - } - else - { - listPerChearchPer = listPerChearch.Where(e => e.YEAR == year && e.MONTH == Month && listGUID.Contains(e.SOURCEID));//综合检查 - } - - if (listPerChearchPer == null || !listPerChearchPer.Any()) - { - listListCount.Add(0); - } - else - { - listListCount.Add(listPerChearchPer.Sum(e => e.COUNT)); - } + listListCount.Add(0); + } + else + { + listListCount.Add(listPerChearchPer.Sum(e => e.COUNT)); } - modelper.listListCount = listListCount; - ListSafeCheckYearMonth.Add(modelper); } - result.ListSafeCheckYearMonth = ListSafeCheckYearMonth.OrderBy(e => e.YEAR).ThenBy(e => e.MONTH).ToList(); + modelper.listListCount = listListCount; + ListSafeCheckYearMonth.Add(modelper); } + result.ListSafeCheckYearMonth = ListSafeCheckYearMonth.OrderBy(e => e.YEAR).ThenBy(e => e.MONTH).ToList(); } + //} #endregion