56
This commit is contained in:
		
							parent
							
								
									a48b8ee4c8
								
							
						
					
					
						commit
						591be7e1d2
					
				@ -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<string> { "ID", "NAME", "DEPARTMENT_TYPE", "PARENT_ID" };
 | 
			
		||||
 | 
			
		||||
                //var listDep1MineType = GetEntities<T_FM_DEPARTMENT>(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<string> { "ID", "NAME", "DEPARTMENT_TYPE", "PARENT_ID" };
 | 
			
		||||
                    List<HomeSafeCheckCountMonth> ListSafeCheckYearMonth = new List<HomeSafeCheckCountMonth>();
 | 
			
		||||
                    int befoMonth = 12;
 | 
			
		||||
                    List<T_BI_HOME_BSRISKREASON> ListSafeCheckYearMonthT = BIHomeService.GetHomeCheckCountMonth(filter.OrgId, listDep.ToList(), befoMonth).ToList();
 | 
			
		||||
                    var listCheckTypeIDT = ListSafeCheckYearMonthT.Select(e => e.SOURCEID).Distinct().ToList();
 | 
			
		||||
 | 
			
		||||
                    //var listDep1MineType = GetEntities<T_FM_DEPARTMENT>(t => t.MineType.HasValue && t.MineType == MineType && t.DEPARTMENT_TYPE == 0, filterD, null);//部门就可以了 因为都相向 统计了
 | 
			
		||||
                    if (listDep != null && listDep.Any())
 | 
			
		||||
                    //var enums = GetEntity<T_FM_ENUMS>(e => e.VALUE == MineType && e.CODE == "BSMineTypeEnum");
 | 
			
		||||
                    //if (enums != null)
 | 
			
		||||
                    //{
 | 
			
		||||
                    //var listTypeMine = GetEntities<MS.Domain.Entities.BS.T_BS_CHECK_TYPE_MINETYPE>(e => e.MINETYPE_ENUMS_ID == enums.ID, null, null);
 | 
			
		||||
                    var listTypeMine = GetEntities<MS.Domain.Entities.BS.T_BS_CHECK_TYPE_MINETYPE>(e => 1 == 1, null, null);
 | 
			
		||||
                    if (listTypeMine != null && listTypeMine.Any())
 | 
			
		||||
                    {
 | 
			
		||||
                        List<HomeSafeCheckCountMonth> ListSafeCheckYearMonth = new List<HomeSafeCheckCountMonth>();
 | 
			
		||||
                        int befoMonth = 12;
 | 
			
		||||
                        List<T_BI_HOME_BSRISKREASON> ListSafeCheckYearMonthT = BIHomeService.GetHomeCheckCountMonth(filter.OrgId, listDep.ToList(), befoMonth).ToList();
 | 
			
		||||
                        var listCheckTypeIDT = ListSafeCheckYearMonthT.Select(e => e.SOURCEID).Distinct().ToList();
 | 
			
		||||
 | 
			
		||||
                        //var enums = GetEntity<T_FM_ENUMS>(e => e.VALUE == MineType && e.CODE == "BSMineTypeEnum");
 | 
			
		||||
                        //if (enums != null)
 | 
			
		||||
                        //{
 | 
			
		||||
                        //var listTypeMine = GetEntities<MS.Domain.Entities.BS.T_BS_CHECK_TYPE_MINETYPE>(e => e.MINETYPE_ENUMS_ID == enums.ID, null, null);
 | 
			
		||||
                        var listTypeMine = GetEntities<MS.Domain.Entities.BS.T_BS_CHECK_TYPE_MINETYPE>(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<MS.Domain.Entities.BS.T_BS_CHECK_TYPE>(e => listCheckTypeIDT.Contains(e.ID), null, null).OrderBy(e => e.PARENT_ID).ThenBy(e => e.NUM).ToList();
 | 
			
		||||
                    var listCheckType = GetEntities<MS.Domain.Entities.BS.T_BS_CHECK_TYPE>(e => listCheckTypeIDT.Contains(e.ID), null, null).OrderBy(e => e.PARENT_ID).ThenBy(e => e.NUM).ToList();
 | 
			
		||||
 | 
			
		||||
                        List<Guid> listCheckTypeID = new List<Guid>();
 | 
			
		||||
                        List<string> listCheckTypeNAME = new List<string>();
 | 
			
		||||
                    List<Guid> listCheckTypeID = new List<Guid>();
 | 
			
		||||
                    List<string> listCheckTypeNAME = new List<string>();
 | 
			
		||||
 | 
			
		||||
                        Guid IDZH = Guid.Empty;//综合检查(只有一个)
 | 
			
		||||
                        List<Guid> listGUID = new List<Guid>();//综合检查子集
 | 
			
		||||
                        for (int i = 0; i < listCheckType.Count; i++)
 | 
			
		||||
                    Guid IDZH = Guid.Empty;//综合检查(只有一个)
 | 
			
		||||
                    List<Guid> listGUID = new List<Guid>();//综合检查子集
 | 
			
		||||
                    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<MS.Domain.Entities.BS.T_BS_CHECK_TYPE>(IDZH);
 | 
			
		||||
                                    listCheckTypeNAME.Add(checkTypeP.NAME);
 | 
			
		||||
                                }
 | 
			
		||||
                                listGUID.Add(listCheckType[i].ID);
 | 
			
		||||
                                IDZH = listCheckType[i].PARENT_ID.Value;
 | 
			
		||||
                                listCheckTypeID.Add(IDZH);
 | 
			
		||||
                                var checkTypeP = GetEntity<MS.Domain.Entities.BS.T_BS_CHECK_TYPE>(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<T_BI_HOME_BSRISKREASON> listPerChearch = null;
 | 
			
		||||
                    IEnumerable<T_BI_HOME_BSRISKREASON> listPerChearchPer = null;
 | 
			
		||||
 | 
			
		||||
                    //List<int> 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<int> listListCount = new List<int>();
 | 
			
		||||
 | 
			
		||||
                        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<T_BI_HOME_BSRISKREASON> listPerChearch = null;
 | 
			
		||||
                        IEnumerable<T_BI_HOME_BSRISKREASON> listPerChearchPer = null;
 | 
			
		||||
 | 
			
		||||
                        //List<int> 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<int> listListCount = new List<int>();
 | 
			
		||||
 | 
			
		||||
                            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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user