diff --git a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FOController.cs b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FOController.cs index 1439864..34d556e 100644 --- a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FOController.cs +++ b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FOController.cs @@ -2386,6 +2386,97 @@ namespace APT.PP.WebApi.Controllers.Api.PP throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); } + return true; + }); + } + + /// + /// 更新岗位当班,交接班,班组活动记录超时字段 + /// + /// + /// + [HttpPost, Route("CurJobSync")] + public JsonActionResult CurJobSync([FromBody] KeywordFilter filter) + { + return SafeExecute(() => + { + try + { + var startTime = DateTime.Now.AddMonths(-3); + var taskIds=new List(); + var curClass = this.GetEntities(t => t.CREATE_TIME >= startTime && t.SHIFT_STATUS == (int)FOShiftStatusEnum.归档 && t.OVERTIME == FOISOVERTIME.未统计, filter); + var curClassIds = curClass.Select(t => t.ID).ToList(); + taskIds.AddRange(curClassIds); + var changeClass = this.GetEntities(t => t.CREATE_TIME >= startTime && t.SHIFT_STATUS == (int)FOChangeShiftStatusEnum.归档 && t.OVERTIME == FOISOVERTIME.未统计, filter); + var changeClassIds = changeClass.Select(t => t.ID).ToList(); + taskIds.AddRange(changeClassIds); + var actClass = this.GetEntities(t => t.CREATE_TIME >= startTime && t.TA_STATUS == (int)FOTeamActivityState.已归档 && t.OVERTIME == FOISOVERTIME.未统计, filter); + var actClassIds = actClass.Select(t => t.ID).ToList(); + taskIds.AddRange(actClassIds); + var tasks = this.GetEntities(t => t.CREATE_TIME >= startTime && t.SOURCE_DATA_ID != null && taskIds.Contains((Guid)t.SOURCE_DATA_ID), filter); + if (curClass != null && curClass.Any()) + { + foreach (var item in curClass) + { + var taskOver = tasks.FirstOrDefault(t => t.SOURCE_DATA_ID == item.ID && t.NOTICE_STATUS == 2); + if (taskOver != null) + { + item.OVERTIME = FOISOVERTIME.超时; + } + else + { + item.OVERTIME = FOISOVERTIME.未超时; + } + } + } + if (changeClass != null && changeClass.Any()) + { + foreach (var item in changeClass) + { + var taskOver = tasks.FirstOrDefault(t => t.SOURCE_DATA_ID == item.ID && t.NOTICE_STATUS == 2); + if (taskOver != null) + { + item.OVERTIME = FOISOVERTIME.超时; + } + else + { + item.OVERTIME = FOISOVERTIME.未超时; + } + } + } + if (actClass != null && actClass.Any()) + { + foreach (var item in actClass) + { + var taskOver = tasks.FirstOrDefault(t => t.SOURCE_DATA_ID == item.ID && t.NOTICE_STATUS == 2); + if (taskOver != null) + { + item.OVERTIME = FOISOVERTIME.超时; + } + else + { + item.OVERTIME = FOISOVERTIME.未超时; + } + } + } + UnifiedCommit(() => + { + if (curClass != null && curClass.Any()) + BantchSaveEntityNoCommit(curClass); + if (changeClass != null && changeClass.Any()) + BantchSaveEntityNoCommit(changeClass); + if (actClass != null && actClass.Any()) + BantchSaveEntityNoCommit(actClass); + }); + } + catch (Exception ex) + { + if (!string.IsNullOrEmpty(ex.StackTrace)) + throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); + else + throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + } + return true; }); } 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 901a822..1203d56 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIHomeController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIHomeController.cs @@ -1292,10 +1292,10 @@ namespace APT.SC.WebApi.Controllers.Api.BI } //redis获取到了数据 - //if (result != null && (result.ListC != null || result.ListCYear != null || result.ListSafeCheckYearMonth != null)) - //{ - // return result; - //} + if (result != null && (result.ListC != null || result.ListCYear != null || result.ListSafeCheckYearMonth != null)) + { + return result; + } #endregion @@ -1330,7 +1330,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI newFilter.IgnoreDataRule = true; var hiddens = GetEntities(e => e.APPLY_DEPARTMENT_ID.HasValue && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Year == dtNow.Year, newFilter); - var startTime = dtNow.AddMonths(-6); + var startTime = dtNow.AddMonths(-5); var currentTime = Convert.ToDateTime(startTime.Year + "-" + startTime.Month + "-01 00:00:00"); //var groupDepart = hiddens.GroupBy(t => t.APPLY_DEPARTMENT_ID); //if (groupDepart.Any()) @@ -1424,7 +1424,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI var val = onTimes.Count() + overTimes.Count(); var count = alls.Count(); HomeCorrect modelC = new HomeCorrect(); - modelC.Val = count == 0 ?"0":((decimal)Math.Round(100.00 * val / count, 2)).ToString(); + modelC.Val = count == 0 ?"100":((decimal)Math.Round(100.00 * val / count, 2)).ToString(); modelC.SOURCENAME = "隐患整改率"; //modelC.DEPARTMENT_ID = (Guid)item.Key; //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; @@ -1435,7 +1435,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI else { HomeCorrect modelC = new HomeCorrect(); - modelC.Val = "0"; + modelC.Val = "100"; modelC.SOURCENAME = "隐患整改率"; //modelC.DEPARTMENT_ID = (Guid)item.Key; //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; @@ -1479,48 +1479,6 @@ namespace APT.SC.WebApi.Controllers.Api.BI #endregion - #region 年度 各下属组织 隐患整改情况 - - List listReasonYearT = BIHomeService.GetHomeCorrectYear(filter.OrgId, listDep).ToList(); - List ListCYear = new List(); - HomeCorrectYear modelCY = null; - int CountYearT = listReasonYearT.Count; - for (int i = 0; i < CountYearT; i++) - { - if (i == 0 || listReasonYearT[i].DEPARTMENT_ID != listReasonYearT[i - 1].DEPARTMENT_ID) - { - modelCY = new HomeCorrectYear(); - modelCY.DEPARTMENTNAME = listReasonYearT[i].DEPARTMENTNAME; - modelCY.DEPARTMENT_ID = listReasonYearT[i].DEPARTMENT_ID; - modelCY.YEAR = listReasonYearT[i].YEAR; - } - - // 按时整改隐患 5 超期整改隐患 10 未整改隐患 15 - if (listReasonYearT[i].SOURCEVAL == 5) - { - modelCY.CountIn += listReasonYearT[i].COUNT; - } - else if (listReasonYearT[i].SOURCEVAL == 10) - { - modelCY.CountOut += listReasonYearT[i].COUNT; - } - else if (listReasonYearT[i].SOURCEVAL == 15) - { - modelCY.CountNot += listReasonYearT[i].COUNT; - } - - if (i == CountYearT - 1 || listReasonYearT[i].DEPARTMENT_ID != listReasonYearT[i + 1].DEPARTMENT_ID) - { - modelCY.Count = modelCY.CountIn + modelCY.CountOut + modelCY.CountNot; - ListCYear.Add(modelCY); - } - } - - result.ListCYear = ListCYear; - - #endregion - - #region 月度 6 个月 安全检查、检查类型 数量 //按生产单元 获取 @@ -1532,11 +1490,11 @@ namespace APT.SC.WebApi.Controllers.Api.BI //filterD.SelectField = new List { "ID", "NAME", "DEPARTMENT_TYPE", "PARENT_ID" }; //var listDep1MineType = GetEntities(t => t.MineType.HasValue && t.MineType == MineType && t.DEPARTMENT_TYPE == 10, filterD, null);//部门就可以了 因为都相向 统计了 - if (listDep != null && listDep.Any()) + //if (listDep != null && listDep.Any()) { List ListSafeCheckYearMonth = new List(); - int befoMonth = 12; - List ListSafeCheckYearMonthT = BIHomeService.GetHomeCheckCountMonth(filter.OrgId, listDep.ToList(), befoMonth).ToList(); + //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"); @@ -1556,13 +1514,13 @@ namespace APT.SC.WebApi.Controllers.Api.BI // } // } //} - var checkIds = ListSafeCheckYearMonthT.Select(t => t.SOURCEID).Distinct().ToList(); - var loginDepart = this.GetEntity(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID); - var listCheckType = GetEntities(e => checkIds.Contains(e.ID), null, null).ToList(); - if (loginDepart != null) - { - listCheckType = listCheckType.Where(t => t.PRODUCTION_UNIT_ID == loginDepart.PRODUCTION_UNIT_ID).ToList(); - } + var checkIds = hiddens.Select(t => t.CHECK_TYPE_ID).Distinct().ToList(); + //var loginDepart = this.GetEntity(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID); + var listCheckType = GetEntities(e => checkIds.Contains(e.ID), null, "Nav_ProductionUnit").ToList(); + //if (loginDepart != null) + //{ + // listCheckType = listCheckType.Where(t => t.PRODUCTION_UNIT_ID == loginDepart.PRODUCTION_UNIT_ID).ToList(); + //} List listCheckTypeID = new List(); List listCheckTypeNAME = new List(); @@ -1584,54 +1542,59 @@ namespace APT.SC.WebApi.Controllers.Api.BI //else { listCheckTypeID.Add(listCheckType[i].ID); - listCheckTypeNAME.Add(listCheckType[i].NAME); + listCheckTypeNAME.Add(listCheckType[i].Nav_ProductionUnit?.NAME + 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) + //IEnumerable listPerChearch = null; + //IEnumerable listPerChearchPer = null; + //var beginTime = Convert.ToDateTime(dtNow.Year + "-01-01 00:00:00"); + //var endTime = Convert.ToDateTime(dtNow.Year + "-12-31 23:59:59"); + for (DateTime i = currentTime; i <= dtNow; i = i.AddMonths(1)) { - 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));//综合检查 - //} + var monthStart = Convert.ToDateTime(i.Year + "-" + i.Month + "-01 00:00:00"); + var monthEnd = Convert.ToDateTime(monthStart.AddMonths(1).AddDays(-1).ToString().Replace("0:00:00", "23:59:59")); + if (i.Date <= startTime.Date) + { + monthStart = startTime; + } + if (i.Date >= dtNow.Date) + { + monthEnd = dtNow; + } + var listPerChearch = hiddens.Where(t => t.CREATE_TIME >= monthStart && t.CREATE_TIME <= monthEnd); + HomeSafeCheckCountMonth modelper = new HomeSafeCheckCountMonth(); + modelper.Total = listPerChearch.Count(); + modelper.listSOURCENAME = listCheckTypeNAME; + modelper.YEAR = monthStart.Year; + modelper.MONTH = monthStart.Month; + List listListCount = new List(); - if (listPerChearchPer == null || !listPerChearchPer.Any()) - { - listListCount.Add(0); + for (int j = 0; j < listCheckTypeID.Count; j++) + { + //if (listCheckTypeID[j] != IDZH) + //{ + var listPerChearchPer = listPerChearch.Where(e => e.CHECK_TYPE_ID == 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.Count()); + } + } + modelper.listListCount = listListCount; + ListSafeCheckYearMonth.Add(modelper); } - 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(); + } } @@ -1641,24 +1604,24 @@ namespace APT.SC.WebApi.Controllers.Api.BI #region 搜索结果 判断存入Redis中 - //if (isRedisConfig) - //{ - // try - // { - // if (listHomeRedis == null) - // listHomeRedis = new List(); + if (isRedisConfig) + { + try + { + if (listHomeRedis == null) + listHomeRedis = new List(); - // listHomeRedis.Add(new HomeResultMineType() - // { - // //MineType = MineType, - // yyyyMMddHH = dtNow.ToString("yyyyMMddHH"), - // result = result - // }); + listHomeRedis.Add(new HomeResultMineType() + { + //MineType = MineType, + yyyyMMddHH = dtNow.ToString("yyyyMMddHH"), + result = result + }); - // CsRedisManager.StringSet>(redisCode, listHomeRedis); - // } - // catch { } - //} + CsRedisManager.StringSet>(redisCode, listHomeRedis); + } + catch { } + } #endregion @@ -1670,8 +1633,8 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 过滤实体 /// - [HttpPost, Route("GetHomeDetailMonthCheckType")] - public JsonActionResult GetHomeDetailMonthCheckType([FromBody] KeywordFilter filter) + [HttpPost, Route("GetHomeDetailMonthCheckTypeOld")] + public JsonActionResult GetHomeDetailMonthCheckTypeOld([FromBody] KeywordFilter filter) { return SafeExecute(() => { @@ -1916,8 +1879,8 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 过滤实体 /// - [HttpPost, Route("GetHomeDetailMonthRisk")] - public JsonActionResult GetHomeDetailMonthRisk([FromBody] KeywordFilter filter) + [HttpPost, Route("GetHomeDetailMonthRiskOld")] + public JsonActionResult GetHomeDetailMonthRiskOld([FromBody] KeywordFilter filter) { return SafeExecute(() => { @@ -2185,193 +2148,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI #endregion - #region 旧版 - - //for (int i = 0; i < listCorrectT.Count; i++) - //{ - // if (i == 0 || listCorrectT[i].DEPARTMENT_ID != listCorrectT[i - 1].DEPARTMENT_ID || listCorrectT[i].SOURCEVAL != listCorrectT[i - 1].SOURCEVAL) - // { - // if (!isNormal && !string.IsNullOrEmpty(Val) && modelC != null) - // { - // modelC.Val = Val + "0"; - // listC.Add(modelC); - // } - - // modelC = new HomeCorrect(); - // modelC.DEPARTMENTNAME = listCorrectT[i].DEPARTMENTNAME; - // modelC.DEPARTMENT_ID = listCorrectT[i].DEPARTMENT_ID; - // modelC.SOURCENAME = listCorrectT[i].SOURCENAME; - // modelC.YEAR = listCorrectT[i].YEAR; - // modelC.NAME = NameMonth; - // Val = ""; - // } - // if (listCorrectT[i].MONTH == 1) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M1 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M1 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M1 + ","; - // } - - - // if (listCorrectT[i].MONTH == 2) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M2 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M2 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M2 + ","; - // } - - // if (listCorrectT[i].MONTH == 3) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M3 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M3 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M3 + ","; - // } - - // if (listCorrectT[i].MONTH == 4) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M4 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M4 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M4 + ","; - // } - - // if (listCorrectT[i].MONTH == 5) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M5 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M5 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M5 + ","; - // } - - // if (listCorrectT[i].MONTH == 6) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M6 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M6 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M6 + ","; - // } - - // if (listCorrectT[i].MONTH == 7) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M7 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M7 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M7 + ","; - // } - - // if (listCorrectT[i].MONTH == 8) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M8 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M8 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M8 + ","; - // } - - // if (listCorrectT[i].MONTH == 9) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M9 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M9 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M9 + ","; - // } - - // if (listCorrectT[i].MONTH == 10) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M10 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M10 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M10 + ","; - // } - - // if (listCorrectT[i].MONTH == 11) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M11 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M11 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M11 + ","; - // } - - // if (listCorrectT[i].MONTH == 12) - // { - // if (listCorrectT[i].SOURCEVAL == 20) - // { - // modelC.M12 = listCorrectT[i].PERCENT.ToString("0.00"); - // } - // else - // { - // modelC.M12 = listCorrectT[i].COUNT.ToString(); - // } - // Val += modelC.M12 + ","; - // } - - // if (isNormal && listCorrectT[i].MONTH == dtNow.Month && listCorrectT[i].YEAR == dtNow.Year) - // { - // //有当月数据 是当前月的时候 放入数据 - // modelC.Val = Val.Substring(0, Val.Length - 1); - // listC.Add(modelC); - // } - //} - - #endregion - + #endregion //var listDepID = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 10).Select(e => e.ID);//部门ID @@ -2498,6 +2275,692 @@ namespace APT.SC.WebApi.Controllers.Api.BI }); } /// + /// 首页 安全检查次数统计明细(BI054HomeDetail) + /// + /// 过滤实体 + /// + [HttpPost, Route("GetHomeDetailMonthCheckType")] + public JsonActionResult GetHomeDetailMonthCheckType([FromBody] KeywordFilter filter) + { + return SafeExecute(() => + { + //按生产单元 获取数据 + HomeDetailSafeCheckCountMonth result = new HomeDetailSafeCheckCountMonth(); + //if (string.IsNullOrEmpty(filter.Keyword)) + //{ + // return result; + //} + //int MineType = int.Parse(filter.Keyword); + var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId; + BaseFilter filterD = new BaseFilter(orgId); + filterD.SelectField = new List { "ID", "NAME", "DEPARTMENT_TYPE", "PARENT_ID" }; + + + var listDep1MineType = GetEntities(t => t.ENABLE_STATUS == 0, filterD, null); + //FMDepartmentType 部门=0, 车间=1, 班组=2, 公司=3 + if (listDep1MineType == null || !listDep1MineType.Any()) + { + return result; + } + List listDepIDCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15).Select(e => e.ID).ToList();//车间ID 用于 统计 每个月各类型的检查数量 + + DateTime dtNow = DateTime.Now; + List listDepCJ = new List(); + List listDepBZ = new List(); + + listDepCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15).OrderBy(e => e.NUM).ToList(); + listDepBZ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 20).OrderBy(e => e.NUM).ToList(); + //T_FM_ENUMS enums = null; + var loginDepart = this.GetEntity(t => t.ID == APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID); + #region 月度 12 个月 安全检查、检查类型 数量 + + //if (listDepCJ == null || listDepCJ.Count < 1 || listDepBZ == null || listDepBZ.Count < 1) + //{ + // ////深度查找 部门 MineType 只能存一个值 + // //enums = GetEntity(e => e.VALUE == MineType && e.CODE == "BSMineTypeEnum"); + // //if (enums == null) + // //{ + // // throw new Exception("获取生产类型失败"); + // //} + // //var listDepID = GetEntities(e => e.ENUMS_ID == enums.ID, null, null).Select(e => e.DEPARTMENT_ID); + // //if (listDepID != null && listDepID.Any()) + // if (loginDepart != null) + // { + // listDep1MineType = GetEntities(t => t.PRODUCTION_UNIT_ID == loginDepart.PRODUCTION_UNIT_ID && (t.DEPARTMENT_TYPE == 15 || t.DEPARTMENT_TYPE == 20), filterD, null); + // if (listDep1MineType != null && listDep1MineType.Any()) + // { + // listDepCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15).ToList(); + // listDepBZ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 20).ToList(); + // } + // } + //} + + //if (listDepCJ == null || listDepCJ.Count < 1 || listDepBZ == null || listDepBZ.Count < 1) + //{ + // throw new Exception("获取生产单元组织信息失败!"); + //} + var newFilter = new BaseFilter(orgId); + newFilter.IgnoreDataRule = true; + var startTime = dtNow.AddMonths(-11); + var hiddens = GetEntities(e => e.APPLY_DEPARTMENT_ID.HasValue && e.CREATE_TIME.HasValue && e.CREATE_TIME >= startTime, newFilter); + + + var currentTime = Convert.ToDateTime(startTime.Year + "-" + startTime.Month + "-01 00:00:00"); + List ListSafeCheckYearMonth = new List(); + //int befoMonth = 11;//计算 12 个月 就是提前 11个月 + //List ListSafeCheckYearMonthT = BIHomeService.GetHomeCheckCountMonth(filter.OrgId, listDep1MineType.ToList(), befoMonth).ToList(); + + var listCheckTypeIDT = hiddens.Select(e => e.CHECK_TYPE_ID).Distinct().ToList(); + //if (enums == null) + //{ + // enums = GetEntity(e => e.VALUE == MineType && e.CODE == "BSMineTypeEnum"); + //} + //if (enums != null) + //{ + // var listTypeMine = GetEntities(e => e.MINETYPE_ENUMS_ID == enums.ID, 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++) + // { + // if (!listMineCheckTypeID.Contains(listCheckTypeIDT[i])) + // { + // listCheckTypeIDT.RemoveAt(i); + // i--; + // } + // } + // } + //} + + var listCheckType = GetEntities(e => listCheckTypeIDT.Contains(e.ID), null, "Nav_ProductionUnit").ToList(); + //if (loginDepart != null) + //{ + // listCheckType = listCheckType.Where(t => t.PRODUCTION_UNIT_ID == loginDepart.PRODUCTION_UNIT_ID).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(); + //Guid IDZH = Guid.Empty;//综合检查(只有一个) + //List listGUID = new List();//综合检查子集 + for (int i = 0; i < listCheckType.Count; i++) + { + //if (listCheckType[i].PARENT_ID.HasValue) + //{ + // 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); + //} + //else + { + listCheckTypeID.Add(listCheckType[i].ID); + listCheckTypeNAME.Add(listCheckType[i].Nav_ProductionUnit?.NAME+listCheckType[i].NAME); + } + } + + //int year = DateTime.Now.Year; + //int Month = DateTime.Now.Month; + //DateTime dtTemp = DateTime.Now; + //IEnumerable listPerChearch = null; + //IEnumerable listPerChearchPer = null; + + for (DateTime i = currentTime; i <= dtNow; i = i.AddMonths(1)) + { + var monthStart = Convert.ToDateTime(i.Year + "-" + i.Month + "-01 00:00:00"); + var monthEnd = Convert.ToDateTime(monthStart.AddMonths(1).AddDays(-1).ToString().Replace("0:00:00", "23:59:59")); + if (i.Date <= startTime.Date) + { + monthStart = startTime; + } + if (i.Date >= dtNow.Date) + { + monthEnd = dtNow; + } + var listPerChearch = hiddens.Where(t => t.CREATE_TIME >= monthStart && t.CREATE_TIME <= monthEnd); + HomeSafeCheckCountMonth modelper = new HomeSafeCheckCountMonth(); + modelper.Total = listPerChearch.Count(); + modelper.listSOURCENAME = listCheckTypeNAME; + modelper.YEAR = monthStart.Year; + modelper.MONTH = monthStart.Month; + List listListCount = new List(); + + for (int j = 0; j < listCheckTypeID.Count; j++) + { + //if (listCheckTypeID[j] != IDZH) + //{ + var listPerChearchPer = listPerChearch.Where(e => e.CHECK_TYPE_ID == 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.Count()); + } + } + modelper.listListCount = listListCount; + ListSafeCheckYearMonth.Add(modelper); + } + + #endregion + + result.ListSafeCheckYearMonth = ListSafeCheckYearMonth.OrderBy(e => e.YEAR).ThenBy(e => e.MONTH).ToList(); + + #region 表数据 + + List listCheckDepCountCJ = new List(); + List listCheckDepCountBZ = new List(); + List listName = new List() { "按时整改隐患", "超期整改隐患", "未整改隐患", "隐患整改率" }; + List listCheckTypeCount = null; + DetailSafeCheckCountDepartment modelCountDep = null; + int checkTypeCount = listCheckTypeID.Count; + foreach (var item in listDepCJ) + { + modelCountDep = new DetailSafeCheckCountDepartment(); + modelCountDep.listName = listName; + modelCountDep.PARENT_ID = item.PARENT_ID.Value; + modelCountDep.Department_ID = item.ID; + modelCountDep.NUM = item.NUM; + modelCountDep.RowCount = listDepBZ.Where(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == item.ID).Count(); + modelCountDep.DepartmentName = item.NAME; + modelCountDep.DepartmentType = item.DEPARTMENT_TYPE; + listCheckTypeCount = new List(); + var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID); + var onTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE <= t.RECITIFY_TIME); + if (onTimes.Any()) + { + listCheckTypeCount.Add(onTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var overTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE > t.RECITIFY_TIME); + if (overTimes.Any()) + { + listCheckTypeCount.Add(overTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var noTimes = alls.Where(t => t.STATUS != BaseData.Domain.Enums.PF.PFStandardStatus.Archived); + if (noTimes.Any()) + { + listCheckTypeCount.Add(noTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + if (alls.Any()) + { + var val = onTimes.Count() + overTimes.Count(); + var count = alls.Count(); + var rate = count == 0 ? 0 : (int)(100.00 * val / count); + listCheckTypeCount.Add(rate); + } + else + { + listCheckTypeCount.Add(100); + } + modelCountDep.listCount = listCheckTypeCount; + listCheckDepCountCJ.Add(modelCountDep); + } + + foreach (var item in listDepBZ) + { + modelCountDep = new DetailSafeCheckCountDepartment(); + modelCountDep.listName = listName; + modelCountDep.PARENT_ID = item.PARENT_ID.Value; + modelCountDep.Department_ID = item.ID; + modelCountDep.NUM = item.NUM; + modelCountDep.RowCount = 1; + modelCountDep.DepartmentName = item.NAME; + modelCountDep.DepartmentType = item.DEPARTMENT_TYPE; + listCheckTypeCount = new List(); + var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID); + var onTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE <= t.RECITIFY_TIME); + if (onTimes.Any()) + { + listCheckTypeCount.Add(onTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var overTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE > t.RECITIFY_TIME); + if (overTimes.Any()) + { + listCheckTypeCount.Add(overTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var noTimes = alls.Where(t => t.STATUS != BaseData.Domain.Enums.PF.PFStandardStatus.Archived); + if (noTimes.Any()) + { + listCheckTypeCount.Add(noTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + if (alls.Any()) + { + var val = onTimes.Count() + overTimes.Count(); + var count = alls.Count(); + var rate = count == 0 ? 0 : (int)(100.00 * val / count); + listCheckTypeCount.Add(rate); + } + else + { + listCheckTypeCount.Add(100); + } + modelCountDep.listCount = listCheckTypeCount; + listCheckDepCountBZ.Add(modelCountDep); + } + + //result.ListSafeCheckCountDepartmentBZ = listCheckDepCountBZ; + foreach (var item in listCheckDepCountCJ) + { + item.listChild = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID).OrderBy(e => e.NUM).ToList(); + } + + #endregion + + //result.ListSafeCheckCountDepartment = listCheckDepCountCJ; + + //取明细 + List ListSafeCheckYearMonthLast = new List(); + int allIndex = 0; + foreach (var item in listCheckDepCountCJ) + { + foreach (var itemC in item.listChild) + { + allIndex++; + itemC.NUM = allIndex; + itemC.Parent = item; + ListSafeCheckYearMonthLast.Add(itemC); + } + } + result.ListSafeCheckCountDepartment = ListSafeCheckYearMonthLast; + + return result; + }); + } + /// + /// 月度隐患整改情况(BI055HomeDetail) + /// + /// 过滤实体 + /// + [HttpPost, Route("GetHomeDetailMonthRisk")] + public JsonActionResult GetHomeDetailMonthRisk([FromBody] KeywordFilter filter) + { + return SafeExecute(() => + { + //按生产单元 获取数据 + HomeDetailRiskCountMonth result = new HomeDetailRiskCountMonth(); + //if (string.IsNullOrEmpty(filter.Keyword)) + //{ + // return result; + //} + //int MineType = int.Parse(filter.Keyword); + var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId; + BaseFilter filterD = new BaseFilter(orgId); + filterD.SelectField = new List { "ID", "NAME", "DEPARTMENT_TYPE", "PARENT_ID" }; + + ///部门 + //var listDep1MineTypeSum = GetEntities(t => t.MineType.HasValue && t.MineType == MineType && t.DEPARTMENT_TYPE == 10, filterD, null); + ///车间 班组 + var listDep1MineType = GetEntities(t => t.ENABLE_STATUS == 0, filterD, null); + + //FMDepartmentType 部门=0, 车间=1, 班组=2, 公司=3 + if (listDep1MineType == null || !listDep1MineType.Any()) + { + return result; + } + + DateTime dtNow = DateTime.Now; + List listDepCJ = new List(); + List listDepBZ = new List(); + + listDepCJ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 15).OrderBy(e => e.NUM).ToList(); + listDepBZ = listDep1MineType.Where(e => e.DEPARTMENT_TYPE == 20).OrderBy(e => e.NUM).ToList(); + + + #region //月度 隐患整改情况 + string Val = string.Empty;// 0 ,1,2,3 + //string NameMonth = dtNow.AddMonths(-5).Month.ToString() + "月," + dtNow.AddMonths(-4).Month.ToString() + "月," + dtNow.AddMonths(-3).Month.ToString() + "月," + dtNow.AddMonths(-2).Month.ToString() + "月," + dtNow.AddMonths(-1).Month.ToString() + "月," + dtNow.Month.ToString() + "月"; + string NameMonth = dtNow.AddMonths(-5).ToString("yyyy-MM") + "," + dtNow.AddMonths(-4).ToString("yyyy-MM") + "," + dtNow.AddMonths(-3).ToString("yyyy-MM") + "," + dtNow.AddMonths(-2).ToString("yyyy-MM") + "," + dtNow.AddMonths(-1).ToString("yyyy-MM") + "," + dtNow.ToString("yyyy-MM"); + List listC = new List(); + //HomeCorrect modelC = null; + bool isNormal = true;//数据是否正常 + var newFilter = new BaseFilter(orgId); + newFilter.IgnoreDataRule = true; + var startTime = dtNow.AddMonths(-11); + var hiddens = GetEntities(e => e.APPLY_DEPARTMENT_ID.HasValue && e.CREATE_TIME.HasValue && e.CREATE_TIME >= startTime, newFilter); + + + var currentTime = Convert.ToDateTime(startTime.Year + "-" + startTime.Month + "-01 00:00:00"); + //var groupDepart = hiddens.GroupBy(t => t.APPLY_DEPARTMENT_ID); + //if (groupDepart.Any()) + { + //foreach (var item in groupDepart) + { + for (DateTime i = currentTime; i <= dtNow; i = i.AddMonths(1)) + { + var monthStart = Convert.ToDateTime(i.Year + "-" + i.Month + "-01 00:00:00"); + var monthEnd = Convert.ToDateTime(monthStart.AddMonths(1).AddDays(-1).ToString().Replace("0:00:00", "23:59:59")); + if (i.Date <= startTime.Date) + { + monthStart = startTime; + } + if (i.Date >= dtNow.Date) + { + monthEnd = dtNow; + } + var alls = hiddens.Where(t => t.CREATE_TIME >= monthStart && t.CREATE_TIME <= monthEnd); + var onTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE <= t.RECITIFY_TIME); + if (onTimes.Any()) + { + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = onTimes.Count().ToString(); + modelC.SOURCENAME = "按时整改隐患"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + else + { + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = "0"; + modelC.SOURCENAME = "按时整改隐患"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + var overTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE > t.RECITIFY_TIME); + if (overTimes.Any()) + { + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = overTimes.Count().ToString(); + modelC.SOURCENAME = "超期整改隐患"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + else + { + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = "0"; + modelC.SOURCENAME = "超期整改隐患"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + var noTimes = alls.Where(t => t.STATUS != BaseData.Domain.Enums.PF.PFStandardStatus.Archived); + if (noTimes.Any()) + { + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = noTimes.Count().ToString(); + modelC.SOURCENAME = "未整改隐患"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + else + { + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = "0"; + modelC.SOURCENAME = "未整改隐患"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + if (alls.Any()) + { + var val = onTimes.Count() + overTimes.Count(); + var count = alls.Count(); + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = count == 0 ? "100" : ((decimal)Math.Round(100.00 * val / count, 2)).ToString(); + modelC.SOURCENAME = "隐患整改率"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + else + { + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = "100"; + modelC.SOURCENAME = "隐患整改率"; + //modelC.DEPARTMENT_ID = (Guid)item.Key; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key)?.NAME; + modelC.YEAR = monthStart.Year; + modelC.NAME = monthStart.ToString("yyyy-MM"); + listC.Add(modelC); + } + } + } + } + List listC2 = new List(); + if (listC.Any()) + { + var groupList = listC.GroupBy(t => new { t.SOURCENAME }); + if (groupList.Any()) + { + foreach (var item in groupList) + { + var vals = listC.Where(t => t.SOURCENAME == item.Key.SOURCENAME).OrderBy(m => m.NAME).Select(n => n.Val).ToList(); + var names = listC.Where(t => t.SOURCENAME == item.Key.SOURCENAME).OrderBy(m => m.NAME).Select(n => n.NAME).ToList(); + HomeCorrect modelC = new HomeCorrect(); + modelC.Val = string.Join(",", vals); + modelC.SOURCENAME = item.Key.SOURCENAME; + //modelC.DEPARTMENT_ID = item.Key.DEPARTMENT_ID; + //modelC.DEPARTMENTNAME = listDep.FirstOrDefault(t => t.ID == item.Key.DEPARTMENT_ID)?.NAME; + modelC.YEAR = dtNow.Year; + modelC.NAME = string.Join(",", names); + listC2.Add(modelC); + } + } + } + + result.ListC = listC2; + + #region 组织合并 + + + #endregion + + + + #endregion + + #region 子表信息 + + //BSCorrectType + //List enums = DataHelper.GetEnum("BSCorrectType"); + + List listName = new List() { "按时整改隐患", "超期整改隐患", "未整改隐患", "隐患整改率" }; + //List listVal = new List(); + //foreach (var item in enums) + //{ + // listVal.Add(item.ID); + // listName.Add(item.NAME); + //} + + List listCheckDepCountCJ = new List(); + List listCheckDepCountBZ = new List(); + + List listCheckTypeCount = null; + DetailSafeCheckCountDepartment modelCountDep = null; + //int checkTypeCount = listVal.Count; + + int Percent = 3;//第4项 是辈分比 + int All = 0; + foreach (var item in listDepCJ) + { + modelCountDep = new DetailSafeCheckCountDepartment(); + modelCountDep.listName = listName; + modelCountDep.PARENT_ID = item.PARENT_ID.Value; + modelCountDep.Department_ID = item.ID; + modelCountDep.NUM = item.NUM; + modelCountDep.RowCount = listDepBZ.Where(e => e.PARENT_ID.HasValue && e.PARENT_ID.Value == item.ID).Count(); + modelCountDep.DepartmentName = item.NAME; + modelCountDep.DepartmentType = item.DEPARTMENT_TYPE; + listCheckTypeCount = new List(); + var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID); + var onTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE <= t.RECITIFY_TIME); + if (onTimes.Any()) + { + listCheckTypeCount.Add(onTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var overTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE > t.RECITIFY_TIME); + if (overTimes.Any()) + { + listCheckTypeCount.Add(overTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var noTimes = alls.Where(t => t.STATUS != BaseData.Domain.Enums.PF.PFStandardStatus.Archived); + if (noTimes.Any()) + { + listCheckTypeCount.Add(noTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + if (alls.Any()) + { + var val = onTimes.Count() + overTimes.Count(); + var count = alls.Count(); + var rate = count == 0 ? 0 : (int)(10000.00 * val / count); + listCheckTypeCount.Add(rate); + } + else + { + listCheckTypeCount.Add(10000); + } + modelCountDep.listCount = listCheckTypeCount; + listCheckDepCountCJ.Add(modelCountDep); + } + + foreach (var item in listDepBZ) + { + modelCountDep = new DetailSafeCheckCountDepartment(); + modelCountDep.listName = listName; + modelCountDep.PARENT_ID = item.PARENT_ID.Value; + modelCountDep.Department_ID = item.ID; + modelCountDep.NUM = item.NUM; + modelCountDep.RowCount = 1; + modelCountDep.DepartmentName = item.NAME; + modelCountDep.DepartmentType = item.DEPARTMENT_TYPE; + listCheckTypeCount = new List(); + var alls = hiddens.Where(t => t.APPLY_DEPARTMENT_ID == item.ID); + var onTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE <= t.RECITIFY_TIME); + if (onTimes.Any()) + { + listCheckTypeCount.Add(onTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var overTimes = alls.Where(t => t.STATUS == BaseData.Domain.Enums.PF.PFStandardStatus.Archived && t.COMPLETE_DATE > t.RECITIFY_TIME); + if (overTimes.Any()) + { + listCheckTypeCount.Add(overTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + var noTimes = alls.Where(t => t.STATUS != BaseData.Domain.Enums.PF.PFStandardStatus.Archived); + if (noTimes.Any()) + { + listCheckTypeCount.Add(noTimes.Count()); + } + else + { + listCheckTypeCount.Add(0); + } + if (alls.Any()) + { + var val = onTimes.Count() + overTimes.Count(); + var count = alls.Count(); + var rate = count == 0 ? 0 : (int)(10000.00 * val / count); + listCheckTypeCount.Add(rate); + } + else + { + listCheckTypeCount.Add(10000); + } + modelCountDep.listCount = listCheckTypeCount; + listCheckDepCountBZ.Add(modelCountDep); + } + + foreach (var item in listCheckDepCountCJ) + { + item.listChild = listCheckDepCountBZ.Where(e => e.PARENT_ID == item.Department_ID).OrderBy(e => e.NUM).ToList(); + } + + //result.ListSafeCheckYearMonth = listCheckDepCountCJ; + + //取明细 + List ListSafeCheckYearMonth = new List(); + int allIndex = 0; + foreach (var item in listCheckDepCountCJ) + { + foreach (var itemC in item.listChild) + { + allIndex++; + itemC.NUM = allIndex; + itemC.Parent = item; + ListSafeCheckYearMonth.Add(itemC); + } + } + + result.ListSafeCheckYearMonth = ListSafeCheckYearMonth; + + #endregion + + return result; + }); + } + /// /// 风险等级占比 /// /// 过滤实体