79 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.Entities.FM;
 | 
						|
using APT.Infrastructure.Core;
 | 
						|
using APT.MS.Domain.Entities.BS;
 | 
						|
using APT.MS.Domain.Entities.DM;
 | 
						|
using APT.MS.Domain.Entities.HM;
 | 
						|
using APT.MS.Domain.Entities.SC.BI;
 | 
						|
using APT.Utility;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using System;
 | 
						|
using System.Linq;
 | 
						|
 | 
						|
namespace APT.SC.WebApi.Controllers.Api.BIController
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// 
 | 
						|
    /// </summary>
 | 
						|
    [Route("api/BI/BIAreaTree")]
 | 
						|
    public partial class AreaTreeController : AuthorizeTreeApiController<T_BI_AREA_TREE>
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="filter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("GetAll")]
 | 
						|
        public JsonActionResult<T_BI_AREA_TREE> GetAll([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                T_BI_AREA_TREE main = new T_BI_AREA_TREE();
 | 
						|
                var id = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
 | 
						|
                if (string.IsNullOrEmpty(id))
 | 
						|
                    throw new Exception("未选中区域");
 | 
						|
                var entity = this.GetEntity<T_BI_AREA_TREE>(id, "Nav_Department");
 | 
						|
                if (entity != null)
 | 
						|
                {
 | 
						|
                    if (entity.DEPARTMENT_ID != null)
 | 
						|
                    {
 | 
						|
                        var users = this.GetEntities<T_FM_USER>(t => t.DEPARTMENT_ID == entity.DEPARTMENT_ID, new BaseFilter(entity.ORG_ID), "Nav_Department", "Nav_Person", "Nav_Person.Nav_Post");
 | 
						|
                        if (users != null && users.Any())
 | 
						|
                        {
 | 
						|
                            entity.Nav_User = users.ToList();
 | 
						|
                        }
 | 
						|
                        var postIds = users.Where(m => m.Nav_Person != null).Select(t => t.Nav_Person.POST_ID).ToList();
 | 
						|
                        var posts = this.GetEntities<T_FM_USER_POST>(t => postIds.Contains(t.ID), new BaseFilter(entity.ORG_ID));
 | 
						|
                        if (posts != null && posts.Any())
 | 
						|
                        {
 | 
						|
                            entity.Nav_Post = posts.ToList();
 | 
						|
                        }
 | 
						|
                        var devices = this.GetEntities<T_DM_DEVICE_BASE>(t => t.DEPARTMENT_ID == entity.DEPARTMENT_ID && postIds.Contains(t.USER_POST_ID), new BaseFilter(entity.ORG_ID));
 | 
						|
                        if (devices != null && devices.Any())
 | 
						|
                        {
 | 
						|
                            entity.Nav_Device = devices.ToList();
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    var risks = this.GetEntities<T_HM_EVALUATE_RISK>(t => t.AREA_ID  == entity.ID, new BaseFilter(entity.ORG_ID));
 | 
						|
                    if (risks != null && risks.Any())
 | 
						|
                    {
 | 
						|
                        entity.Nav_Risk = risks.ToList();
 | 
						|
                    }
 | 
						|
                    var submits = this.GetEntities<T_BS_RISK_SUBMIT_CONTENT>(t => t.RISK_AREA_ID == entity.ID, new BaseFilter(entity.ORG_ID));
 | 
						|
                    if (submits != null && submits.Any())
 | 
						|
                    {
 | 
						|
                        entity.Nav_Submit = submits.ToList();
 | 
						|
                    }
 | 
						|
                    var checkAeas = this.GetEntities<T_BS_SAFE_CHECK_RISK_AREA>(t => t.RISK_AREA_ID == entity.ID, new BaseFilter(entity.ORG_ID));
 | 
						|
                    var checkIds = checkAeas.Select(t => t.SAFE_CHECK_ID).Distinct().ToList();
 | 
						|
                    var checks = this.GetEntities<T_BS_SAFE_CHECK>(t => checkIds.Contains(t.ID), new BaseFilter(entity.ORG_ID));
 | 
						|
                    if (checks != null && checks.Any())
 | 
						|
                    {
 | 
						|
                        entity.Nav_Check = checks.ToList();
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                return entity;
 | 
						|
            });
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |