using APT.BaseData.Domain.Entities;
using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Enums.PF;
using APT.BaseData.Domain.IServices;
using APT.BaseData.Domain.IServices.AE;
using APT.BaseData.Domain.IServices.FM;
using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.HM;
using APT.MS.Domain.Entities.OH;
using APT.MS.Domain.Entities.PF;
using APT.MS.Domain.Entities.SC;
using APT.MS.Domain.Entities.TI;
using APT.MS.Domain.Enums;
using APT.Utility;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace APT.SC.WebApi.Controllers.Api.OH
{
    [Route("api/OH/OHHealthEaxmPlanDepartment")]
    public class OHHealthExamPlanDepartmentController : AuthorizeApiController<T_OH_HEALTH_EAXM_PLAN_DEPARTMENT>
    {
        IFMFlowPermitService MFlowPermitService { get; set; }
        IPFApproveCallBackService ApproveCallBackService { get; set; }
        IAEAccidentEventReportService AccidentEventReportService { get; set; }
        IFMNotificationTaskService NotificationTaskService { get; set; }
        IFMUserService UserService { get; set; }
        IFMDepartmentService DepartmentService { get; set; }
        public OHHealthExamPlanDepartmentController(IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService, IAEAccidentEventReportService accidentEventReportService, IFMNotificationTaskService notificationTaskService, IFMUserService userService, IFMDepartmentService departmentService)
        {
            MFlowPermitService = mFlowPermitService;
            ApproveCallBackService = approveCallBackService;
            AccidentEventReportService = accidentEventReportService;
            NotificationTaskService = notificationTaskService;
            UserService = userService;
            DepartmentService = departmentService;
        }

        /// <summary>
        /// 获得单条实体数据
        /// </summary>
        /// <param name="filter">过滤实体</param>
        /// <returns></returns>
        [HttpPost, Route("GetDep")]
        public JsonActionResult<T_OH_HEALTH_EAXM_PLAN_DEPARTMENT> GetDep([FromBody] KeywordFilter filter)
        {
            return SafeExecute(() =>
            {
                var result = GetEntity<T_OH_HEALTH_EAXM_PLAN_DEPARTMENT>(null, filter, null);
                if (result.Nav_Plan.Nav_ListPlanRegister != null && result.Nav_Plan.Nav_ListPlanRegister.Any())
                {
                    result.Nav_Plan.Nav_ListPlanRegister = result.Nav_Plan.Nav_ListPlanRegister.Where(e => e.PLAN_ID_DEP == result.ID).ToList();
                }
                return result;
            });
        }
    }
}