591 lines
		
	
	
		
			29 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			591 lines
		
	
	
		
			29 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.Entities.FM;
 | 
						|
using APT.Infrastructure.Core;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using APT.Infrastructure.Api;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System;
 | 
						|
using System.Linq;
 | 
						|
using APT.MS.Domain.Enums;
 | 
						|
using APT.MS.Domain.Entities.HM;
 | 
						|
using APT.BaseData.Domain.Enums;
 | 
						|
using APT.Utility;
 | 
						|
using APT.MS.Domain.Entities.SE;
 | 
						|
using APT.MS.Domain.Entities.BI;
 | 
						|
using NPOI.SS.Formula.Functions;
 | 
						|
using APT.BaseData.Domain.Entities;
 | 
						|
using APT.MS.Domain.Entities.SC.BI;
 | 
						|
using System.Collections.ObjectModel;
 | 
						|
using APT.BaseData.Domain.Entities.OP;
 | 
						|
using APT.Migrations;
 | 
						|
using APT.BaseData.Services.Services.FM;
 | 
						|
using APT.BaseData.Domain.IServices.FM;
 | 
						|
 | 
						|
namespace APT.SC.WebApi.Controllers.Api.BI
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    ///  年度监测汇总
 | 
						|
    /// </summary>
 | 
						|
    [Route("api/BI/BIController")]
 | 
						|
    public class BIController : APTApiController<T_FM_WORK_TICKET_COMPLETION>
 | 
						|
    {
 | 
						|
        
 | 
						|
        public class GoViewDataReturn
 | 
						|
        {
 | 
						|
            public int code { get; set; }
 | 
						|
            public int count { get; set; }
 | 
						|
            public string msg { get; set; }
 | 
						|
            public object data { get; set; }
 | 
						|
        }
 | 
						|
        public class EchartsDataset
 | 
						|
        {
 | 
						|
            public string[] dimensions { get; set; }
 | 
						|
            public List<object> source { get; set; }
 | 
						|
        }
 | 
						|
        public class addItem
 | 
						|
        {
 | 
						|
            public string 班组名称 { get; set; }
 | 
						|
            public int 待办 { get; set; }
 | 
						|
            public int 总数 { get; set; }
 | 
						|
 | 
						|
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 班前会议数量统计
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">分页过滤实体</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("PreShiftMeetingCount")]
 | 
						|
        public GoViewDataReturn PreShiftMeetingCount(string param)
 | 
						|
        {
 | 
						|
            //var paramArr = param.Trim('"').Split("|");
 | 
						|
            Guid orgId = getOrgIdByTenant(this.Request.Headers["Tenant"]);
 | 
						|
            GoViewDataReturn goViewDataReturn = new GoViewDataReturn()
 | 
						|
            {
 | 
						|
                msg = "",
 | 
						|
                code = 200
 | 
						|
            };
 | 
						|
            var result = GetEntities<T_FM_DEPARTMENT_COMPLETION>(t => t.FORM_NAME == "班前会议", new BaseFilter(orgId));
 | 
						|
            EchartsDataset dataset = new EchartsDataset();
 | 
						|
            dataset.dimensions = new string[] { "班组名称", "待办", "总数" };
 | 
						|
            dataset.source = new List<object>();
 | 
						|
            foreach (var item in result)
 | 
						|
            {
 | 
						|
                var test = new addItem
 | 
						|
                {
 | 
						|
                    班组名称 = item.TEAM_NAME,
 | 
						|
                    待办 = item.WAITTING_COUNT,
 | 
						|
                    总数 = item.TOTAL_COUNT
 | 
						|
                };
 | 
						|
                dataset.source.Add(test);
 | 
						|
            }
 | 
						|
            goViewDataReturn.data = dataset;
 | 
						|
            return goViewDataReturn;
 | 
						|
        }
 | 
						|
        private Guid getOrgIdByTenant(string Tenant)
 | 
						|
        {
 | 
						|
            Guid orgId = Guid.Empty;
 | 
						|
            if (Tenant.Equals("0001"))//XLK
 | 
						|
            {
 | 
						|
                orgId = Guid.Parse("b043b28b-bbc3-c452-6052-4fba1457abfa");
 | 
						|
            }
 | 
						|
            else if (Tenant.Equals("A0000024"))//豫鹭
 | 
						|
            {
 | 
						|
                orgId = Guid.Parse("d9871ba8-0eec-9e4a-bb87-7d5a540d8913");
 | 
						|
            }
 | 
						|
            else if (Tenant.Equals("A0000025"))//金鼎
 | 
						|
            {
 | 
						|
                orgId = Guid.Parse("8b3c41aa-51b1-7ce9-1879-248a038c1b5c");
 | 
						|
            }
 | 
						|
            else if (Tenant.Equals("0002"))//龙岩稀土
 | 
						|
            {
 | 
						|
                orgId = Guid.Parse("8f1cf418-8bf3-ea3f-7a6d-fc5d61247008");
 | 
						|
            }
 | 
						|
            return orgId;
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 返回系统用户数
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">返回系统用户数</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("userCount")]
 | 
						|
        public JsonActionResult<int> userCount([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<int>(() =>
 | 
						|
            {
 | 
						|
                return GetCount<T_FM_USER>(t => t.ENABLE_STATUS == 0, new BaseFilter(filter.GetOrgId()));
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 风险库统计
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">返回系统用户数</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("savesouceDepartment")]
 | 
						|
        public JsonActionResult<bool> savesouceDepartment([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
                var riskFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                riskFilter.Include = new string[] { "Nav_DepartmentLiable.Nav_Parent.Nav_Parent" };
 | 
						|
                var all = GetEntities<T_HM_EVALUATE_RISK>(t => t.STATUS == (int)HMOperationStepEnum.有效 && t.DEPARTMENT_LIABLE_ID != null && t.SOURCE_DEPARTMENT_ID == null, riskFilter);
 | 
						|
                foreach (var entity in all)
 | 
						|
                {
 | 
						|
                    if (entity.Nav_DepartmentLiable.DEPARTMENT_TYPE == (int)FMDepartmentType.班组)
 | 
						|
                    {
 | 
						|
                        entity.SOURCE_DEPARTMENT_ID = entity.Nav_DepartmentLiable.Nav_Parent.Nav_Parent.ID;
 | 
						|
                    }
 | 
						|
                    if (entity.Nav_DepartmentLiable.DEPARTMENT_TYPE == (int)FMDepartmentType.车间)
 | 
						|
                    {
 | 
						|
                        entity.SOURCE_DEPARTMENT_ID = entity.Nav_DepartmentLiable.Nav_Parent.ID;
 | 
						|
                    }
 | 
						|
                    if (entity.Nav_DepartmentLiable.DEPARTMENT_TYPE == (int)FMDepartmentType.部门)
 | 
						|
                    {
 | 
						|
                        entity.SOURCE_DEPARTMENT_ID = entity.DEPARTMENT_LIABLE_ID;
 | 
						|
                    }
 | 
						|
                    entity.Nav_DepartmentLiable = null;
 | 
						|
                }
 | 
						|
                this.UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    BantchUpdateEntityNoCommit(all);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        public class riskData
 | 
						|
        {
 | 
						|
            public List<riskLevelCountModel> RISKLEVELCOUNTS { get; set; }
 | 
						|
            public List<areaCountModel> AREACOUNTS { get; set; }
 | 
						|
            public List<dateCountModel> DATECOUNTS { get; set; }
 | 
						|
            public int RISKTOTALCOUNT { get; set; }
 | 
						|
            public int HAZARDTOTALCOUNT { get; set; }
 | 
						|
            public int MEASURESTOTALCOUNT { get; set; }
 | 
						|
 | 
						|
        }
 | 
						|
        public class areaCountModel
 | 
						|
        {
 | 
						|
            public string AREANAME { get; set; }
 | 
						|
            public int AREACOUNT { get; set; }
 | 
						|
            public int AREATYPE { get; set; }
 | 
						|
        }
 | 
						|
        public class riskLevelCountModel
 | 
						|
        {
 | 
						|
            public string NAME { get; set; }
 | 
						|
            public int LEVEL1 { get; set; }
 | 
						|
            public int LEVEL2 { get; set; }
 | 
						|
            public int LEVEL3 { get; set; }
 | 
						|
            public int LEVEL4 { get; set; }
 | 
						|
        }
 | 
						|
        public class dateCountModel
 | 
						|
        {
 | 
						|
            public DateTime DATE { get; set; }
 | 
						|
            public int COUNT { get; set; }
 | 
						|
            public int TYPE { get; set; }
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 风险库统计
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">返回系统用户数</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("getRiskData")]
 | 
						|
        public JsonActionResult<riskData> getRiskData([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<riskData>(() =>
 | 
						|
            {
 | 
						|
                var riskFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                riskFilter.SelectField = new string[] { "AREA_ID", "Nav_Area.NAME", "EVALUATE_LEVEL", "Nav_SourceDepartment.NAME", "CREATE_TIME" };
 | 
						|
                IEnumerable<T_HM_EVALUATE_RISK> allrisk = null;
 | 
						|
                if (filter.Parameter1 != null)
 | 
						|
                {
 | 
						|
                    allrisk = GetEntities<T_HM_EVALUATE_RISK>(t => t.STATUS == (int)HMOperationStepEnum.有效 && t.SOURCE_DEPARTMENT_ID != null && t.MineType == int.Parse(filter.Parameter1), riskFilter);
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    allrisk = GetEntities<T_HM_EVALUATE_RISK>(t => t.STATUS == (int)HMOperationStepEnum.有效 && t.SOURCE_DEPARTMENT_ID != null, riskFilter);
 | 
						|
                }
 | 
						|
                var hazardFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                hazardFilter.SelectField = new string[] { "CREATE_TIME" };
 | 
						|
                var allhazard = GetEntities<T_HM_EVALUATE_HAZARD>(t => t.STATUS == (int)HMOperationStepEnum.有效, hazardFilter);
 | 
						|
                var measureFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                measureFilter.SelectField = new string[] { "NAME" };
 | 
						|
                var measure1 = GetEntities<T_HM_INDIVIDUAL_MEASURES>(t => t.IS_DELETED == false, measureFilter).Select(t => t.NAME).Distinct().Count();
 | 
						|
                var measure2 = GetEntities<T_HM_EDUCATION_MEASURES>(t => t.IS_DELETED == false, measureFilter).Select(t => t.NAME).Distinct().Count();
 | 
						|
                var measure3 = GetEntities<T_HM_EMERGENCY_MEASURES>(t => t.IS_DELETED == false, measureFilter).Select(t => t.NAME).Distinct().Count();
 | 
						|
                var measure4 = GetEntities<T_HM_ENGINEERING_MEASURES>(t => t.IS_DELETED == false, measureFilter).Select(t => t.NAME).Distinct().Count();
 | 
						|
                var measure5 = GetEntities<T_HM_MANAGEMENT_MEASURES>(t => t.IS_DELETED == false, measureFilter).Select(t => t.NAME).Distinct().Count();
 | 
						|
                //var distinctDepartment = allrisk.Select(t => new { t.SOURCE_DEPARTMENT_ID, t.Nav_SourceDepartment.NAME }).Distinct();
 | 
						|
                var distinctDepartment = GetEntities<T_FM_DEPARTMENT>(t => t.DEPARTMENT_TYPE == 0, new BaseFilter(filter.GetOrgId()));
 | 
						|
 | 
						|
                riskData riskData = new riskData();
 | 
						|
                List<riskLevelCountModel> item1s = new List<riskLevelCountModel>();
 | 
						|
                List<areaCountModel> item2s = new List<areaCountModel>();
 | 
						|
                List<dateCountModel> item3s = new List<dateCountModel>();
 | 
						|
 | 
						|
                foreach (var department in distinctDepartment)
 | 
						|
                {
 | 
						|
                    riskLevelCountModel item = new riskLevelCountModel();
 | 
						|
                    item.NAME = department.NAME;
 | 
						|
                    item.LEVEL1 = allrisk.Count(t => t.SOURCE_DEPARTMENT_ID == department.ID && t.EVALUATE_LEVEL == EvaluateLevelEnum.一级);
 | 
						|
                    item.LEVEL2 = allrisk.Count(t => t.SOURCE_DEPARTMENT_ID == department.ID && t.EVALUATE_LEVEL == EvaluateLevelEnum.二级);
 | 
						|
                    item.LEVEL3 = allrisk.Count(t => t.SOURCE_DEPARTMENT_ID == department.ID && t.EVALUATE_LEVEL == EvaluateLevelEnum.三级);
 | 
						|
                    item.LEVEL4 = allrisk.Count(t => t.SOURCE_DEPARTMENT_ID == department.ID && t.EVALUATE_LEVEL == EvaluateLevelEnum.四级);
 | 
						|
                    item1s.Add(item);
 | 
						|
                }
 | 
						|
                var distinctArea = allrisk.Select(t => new { t.AREA_ID, AreaName = t.Nav_Area.NAME, SourceDepartmentName = t.Nav_SourceDepartment.NAME }).Distinct();
 | 
						|
                foreach (var area in distinctArea)
 | 
						|
                {
 | 
						|
 | 
						|
                    if (area.SourceDepartmentName.Contains("矿山") || area.SourceDepartmentName.Contains("选矿"))
 | 
						|
                    {
 | 
						|
                        areaCountModel item = new areaCountModel();
 | 
						|
 | 
						|
                        if (area.SourceDepartmentName.Contains("矿山"))
 | 
						|
                        {
 | 
						|
                            item.AREATYPE = 0;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            item.AREATYPE = 1;
 | 
						|
                        }
 | 
						|
                        item.AREANAME = area.AreaName;
 | 
						|
                        item.AREACOUNT = allrisk.Count(t => t.AREA_ID == area.AREA_ID);
 | 
						|
                        item2s.Add(item);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                var currMonth = DateTime.Now.Month;
 | 
						|
                DateTime today = DateTime.Today;
 | 
						|
                for (var i = 1; i < currMonth + 1; i++)
 | 
						|
                {
 | 
						|
                    DateTime endOfMonth = new DateTime(today.Year, i, 1).AddMonths(1).AddSeconds(-1);
 | 
						|
                    dateCountModel riskDate = new dateCountModel();
 | 
						|
                    riskDate.DATE = endOfMonth;
 | 
						|
                    riskDate.COUNT = allrisk.Count(t => t.CREATE_TIME <= endOfMonth);
 | 
						|
                    riskDate.TYPE = 0;
 | 
						|
                    item3s.Add(riskDate);
 | 
						|
                    dateCountModel hazardDate = new dateCountModel();
 | 
						|
                    hazardDate.DATE = endOfMonth;
 | 
						|
                    hazardDate.COUNT = allhazard.Count(t => t.CREATE_TIME <= endOfMonth); ;
 | 
						|
                    hazardDate.TYPE = 1;
 | 
						|
                    item3s.Add(hazardDate);
 | 
						|
                }
 | 
						|
                riskData.RISKLEVELCOUNTS = item1s.OrderByDescending(t => t.LEVEL4).ToList();
 | 
						|
                riskData.AREACOUNTS = item2s.OrderBy(t => t.AREACOUNT).ToList();
 | 
						|
                riskData.DATECOUNTS = item3s.OrderBy(t => t.DATE).ToList();
 | 
						|
                riskData.RISKTOTALCOUNT = allrisk.Count();
 | 
						|
                riskData.HAZARDTOTALCOUNT = allhazard.Count();
 | 
						|
                riskData.MEASURESTOTALCOUNT = measure1 + measure2 + measure3 + measure4 + measure5;
 | 
						|
                return riskData;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        public class safeTrainData
 | 
						|
        {
 | 
						|
            /// 年度培训计划完成率
 | 
						|
            public int NUM1 { get; set; }
 | 
						|
            /// 安全培训教育
 | 
						|
            public int NUM2 { get; set; }
 | 
						|
            /// 三级安全教育
 | 
						|
            public int NUM3 { get; set; }
 | 
						|
            /// 学时达标率
 | 
						|
            public int NUM4 { get; set; }
 | 
						|
            /// 培训优良率
 | 
						|
            public int NUM5 { get; set; }
 | 
						|
            /// 培训考核通过率
 | 
						|
            public int NUM6 { get; set; }
 | 
						|
            /// 题库总条数
 | 
						|
            public int NUM7 { get; set; }
 | 
						|
            public List<trainRecords> trainRecords { get; set; }
 | 
						|
            public List<dateCountModel> dateCountModel { get; set; }
 | 
						|
 | 
						|
 | 
						|
        }
 | 
						|
        public class trainRecords
 | 
						|
        {
 | 
						|
            /// 课程名称
 | 
						|
            public string NAME { get; set; }
 | 
						|
            /// 培训起止时间
 | 
						|
            public string TIMERANGE { get; set; }
 | 
						|
            /// 应参训人数
 | 
						|
            public int SHOULD_TRAINER { get; set; }
 | 
						|
            /// 实际参训人数
 | 
						|
            public int ACTUAL_TRAINER { get; set; }
 | 
						|
            /// 参训率
 | 
						|
            public string TRAINER_RATE { get; set; }
 | 
						|
            /// 考核方式
 | 
						|
            public string METHOD { get; set; }
 | 
						|
            /// 通过率
 | 
						|
            public string PASS_RATE { get; set; }
 | 
						|
            /// 效果评估(优良率)
 | 
						|
            public string EFFORT_RATE { get; set; }
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 安全培训教育统计分析
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">返回系统用户数</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("getSafeTrainData")]
 | 
						|
        public JsonActionResult<safeTrainData> getSafeTrainData([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<safeTrainData>(() =>
 | 
						|
            {
 | 
						|
                var riskFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                riskFilter.Include = new string[] { "Nav_Notify.Nav_TrainUserList", "Nav_Users", "Nav_Notify.Nav_TrainCheckType" };
 | 
						|
                DateTime time = DateTime.Parse(filter.Parameter1);
 | 
						|
                DateTime currYear = DateTime.Parse(time.Year + " 01-01");
 | 
						|
                var startTime = time.AddDays(1 - time.Day);
 | 
						|
                var endTime = time.AddDays(1 - time.Day).AddMonths(1);
 | 
						|
                var records = GetEntities<T_SE_TRAIN_RECORD>(t => t.CREATE_TIME > currYear, riskFilter);
 | 
						|
                var testCount = GetCount<T_SE_TEST>(t => t.IS_DELETED == false, new BaseFilter(filter.GetOrgId()));
 | 
						|
                var threeLevelCount = GetCount<T_SE_THREE_LEVEL_SAFE_EDU_CARD>(t => t.IS_DELETED == false, new BaseFilter(filter.GetOrgId()));
 | 
						|
                var currMonthrecords = records.Where(t => t.CREATE_TIME > startTime && t.CREATE_TIME < endTime).OrderBy(t => t.Nav_Notify.TRAIN_START_TIME);
 | 
						|
                var recordids = currMonthrecords.Select(t => t.ID);
 | 
						|
                var examFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                examFilter.SelectField = new string[] { "USER_ID", "RECORD_ID", "SCORE" };
 | 
						|
                var exams = GetEntities<T_SE_TRAIN_RECORD_PAPER>(t => recordids.Contains(t.RECORD_ID), examFilter).DistinctBy(t => t.USER_ID);
 | 
						|
                var notifyIds = currMonthrecords.Select(t => t.NOTIFY_ID);
 | 
						|
                var effectFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                effectFilter.Include = new string[] { "Nav_ResultList" };
 | 
						|
                var effects = GetEntities<T_SE_TRAINING_EFFECT_EVALUATION>(t => notifyIds.Contains((Guid)t.SURVEY_ID), effectFilter);
 | 
						|
 | 
						|
                List<trainRecords> trainRecords = new List<trainRecords>();
 | 
						|
                foreach (var item in currMonthrecords)
 | 
						|
                {
 | 
						|
                    trainRecords trainRecord = new trainRecords();
 | 
						|
                    trainRecord.NAME = item.Nav_Notify.NAME;
 | 
						|
                    trainRecord.TIMERANGE = item.Nav_Notify.TRAIN_START_TIME + "-" + item.Nav_Notify.TRAIN_END_TIME;
 | 
						|
                    trainRecord.SHOULD_TRAINER = item.Nav_Notify.Nav_TrainUserList.Count();
 | 
						|
                    trainRecord.ACTUAL_TRAINER = item.Nav_Users.Count();
 | 
						|
                    trainRecord.METHOD = item.Nav_Notify.Nav_TrainCheckType.NAME;
 | 
						|
                    if (item.Nav_Notify.Nav_TrainCheckType.NAME == "笔试")
 | 
						|
                    {
 | 
						|
                        var currExams = exams.Where(t => t.RECORD_ID == item.ID);
 | 
						|
                        var currCount = currExams.Count();
 | 
						|
                        if (currCount > 0)
 | 
						|
                        {
 | 
						|
                            var passExams = currExams.Where(t => t.SCORE >= 80);
 | 
						|
                            var passCount = passExams.Count();
 | 
						|
                            var rate = (passCount * 1.0 / currCount);
 | 
						|
                            trainRecord.PASS_RATE = rate.ToString();
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            trainRecord.PASS_RATE = "0";
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        trainRecord.PASS_RATE = "1";
 | 
						|
                    }
 | 
						|
                    if (item.Nav_Notify.NEED_EVALUATION == SETrainNeedSuvey.是)
 | 
						|
                    {
 | 
						|
                        var effect = effects.FirstOrDefault(t => t.SURVEY_ID == item.NOTIFY_ID);
 | 
						|
                        if (effect != null)
 | 
						|
                        {
 | 
						|
                            var effectResult = effect.Nav_ResultList;
 | 
						|
                            double sumTotal = 0;
 | 
						|
                            foreach (var item2 in effectResult)
 | 
						|
                            {
 | 
						|
                                double num1 = Convert.ToDouble(item2.GOOD_RATION.Replace("%", ""));
 | 
						|
                                double num2 = Convert.ToDouble(item2.BETTER_RATION.Replace("%", ""));
 | 
						|
                                sumTotal += num1;
 | 
						|
                                sumTotal += num2;
 | 
						|
                            }
 | 
						|
                            trainRecord.EFFORT_RATE = (sumTotal / effectResult.Count()).ToString();
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            trainRecord.EFFORT_RATE = "100";
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        trainRecord.EFFORT_RATE = "100";
 | 
						|
 | 
						|
                    }
 | 
						|
                    trainRecords.Add(trainRecord);
 | 
						|
                }
 | 
						|
                List<dateCountModel> item3s = new List<dateCountModel>();
 | 
						|
                DateTime today = DateTime.Today;
 | 
						|
                for (var i = 1; i < DateTime.Now.Month + 1; i++)
 | 
						|
                {
 | 
						|
                    DateTime startTime1 = new DateTime(today.Year, i, 1);
 | 
						|
                    DateTime endTime1 = new DateTime(today.Year, i, 1).AddMonths(1).AddSeconds(-1);
 | 
						|
                    dateCountModel riskDate = new dateCountModel();
 | 
						|
                    riskDate.DATE = startTime1;
 | 
						|
                    riskDate.COUNT = records.Count(t => t.CREATE_TIME > startTime1 && t.CREATE_TIME < endTime1);
 | 
						|
                    item3s.Add(riskDate);
 | 
						|
                }
 | 
						|
                safeTrainData safeTrainData = new safeTrainData();
 | 
						|
                safeTrainData.NUM1 = 1;
 | 
						|
                safeTrainData.NUM2 = records.Count();
 | 
						|
                safeTrainData.NUM3 = threeLevelCount;
 | 
						|
                safeTrainData.NUM4 = 13;
 | 
						|
                safeTrainData.NUM5 = 14;
 | 
						|
                safeTrainData.NUM6 = 15;
 | 
						|
                safeTrainData.NUM7 = testCount;
 | 
						|
                safeTrainData.trainRecords = trainRecords;
 | 
						|
                safeTrainData.dateCountModel = item3s;
 | 
						|
                return safeTrainData;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        ///// <summary>
 | 
						|
        ///// 获取版本号
 | 
						|
        ///// </summary>
 | 
						|
        ///// <param name="pageFilter">获取版本号</param>
 | 
						|
        ///// <returns></returns>
 | 
						|
        [HttpPost, Route("getVersion")]
 | 
						|
        public JsonActionResult<dynamic> getVersion([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<dynamic>(() =>
 | 
						|
            {
 | 
						|
                dynamic ret = new System.Dynamic.ExpandoObject();
 | 
						|
                using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
 | 
						|
                {
 | 
						|
                    var version = context.GetEntity<T_OP_VERSION>(i => i.IS_DELETED == false, new string[] { "VERSION_NO" });
 | 
						|
                    if (version != null)
 | 
						|
                    {
 | 
						|
                        ret = version.VERSION_NO;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                return ret;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        public class notificationData
 | 
						|
        {
 | 
						|
            /// 模块
 | 
						|
            public string NAME1 { get; set; }
 | 
						|
            /// 表单名称
 | 
						|
            public string NAME2 { get; set; }
 | 
						|
            /// 待办数
 | 
						|
            public double NAME3 { get; set; }
 | 
						|
            /// 完成数
 | 
						|
            public double NAME4 { get; set; }
 | 
						|
            /// 完成率
 | 
						|
            public string NAME5 { get; set; }
 | 
						|
            /// 及时完成率
 | 
						|
            public string NAME6 { get; set; }
 | 
						|
            /// 总数
 | 
						|
            public double NAME7 { get; set; }
 | 
						|
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 待办统计
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">待办统计</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("getNotificationTask")]
 | 
						|
        public JsonActionResult<List<notificationData>> getNotificationTask([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<List<notificationData>>(() =>
 | 
						|
            {
 | 
						|
                dynamic ret = new System.Dynamic.ExpandoObject();
 | 
						|
                var riskFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                riskFilter.SelectField = new string[] { "NOTICE_STATUS", "SOURCE_FORMCODE" };
 | 
						|
                DateTime currYear = DateTime.Parse(filter.Parameter1);
 | 
						|
                var records = GetEntities<T_FM_NOTIFICATION_TASK>(t => t.CREATE_TIME > currYear, riskFilter);
 | 
						|
 | 
						|
                var formFilter = new BaseFilter(filter.GetOrgId());
 | 
						|
                riskFilter.SelectField = new string[] { "CODE", "NAME" };
 | 
						|
                var pfForms = GetEntities<T_PF_FORM>(t => t.IS_DELETED == false, riskFilter).Select(t => new { t.CODE, t.NAME }).Distinct();
 | 
						|
                List<notificationData> notificationDatas = new List<notificationData>();
 | 
						|
 | 
						|
                foreach (var item in pfForms)
 | 
						|
                {
 | 
						|
                    var total = records.Where(t => t.SOURCE_FORMCODE == item.CODE);
 | 
						|
                    double totalCount = total.Count();
 | 
						|
                    if (totalCount > 0)
 | 
						|
                    {
 | 
						|
 | 
						|
                        notificationData notificationData = new notificationData();
 | 
						|
                        notificationData.NAME1 = item.CODE;
 | 
						|
                        notificationData.NAME2 = item.NAME;
 | 
						|
                        notificationData.NAME3 = total.Count(t => t.NOTICE_STATUS == 0);
 | 
						|
                        notificationData.NAME4 = total.Count(t => t.NOTICE_STATUS > 0);
 | 
						|
                        notificationData.NAME5 = ((notificationData.NAME4 / totalCount) * 100).ToString("0.00");
 | 
						|
                        var inTime = total.Count(t => t.NOTICE_STATUS == 1);
 | 
						|
                        notificationData.NAME6 = ((inTime / totalCount) * 100).ToString("0.00");
 | 
						|
                        notificationData.NAME7 = totalCount;
 | 
						|
                        notificationDatas.Add(notificationData);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                return notificationDatas;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        public class schedulingData
 | 
						|
        {
 | 
						|
            /// 模块
 | 
						|
            public string NAME1 { get; set; }
 | 
						|
            /// 表单名称
 | 
						|
            public string NAME2 { get; set; }
 | 
						|
            /// 待办数
 | 
						|
            public string NAME3 { get; set; }
 | 
						|
            /// 完成数
 | 
						|
            public string NAME4 { get; set; }
 | 
						|
            /// 完成率
 | 
						|
            public string NAME5 { get; set; }
 | 
						|
            /// 及时完成率
 | 
						|
            public string NAME6 { get; set; }
 | 
						|
            /// 总数
 | 
						|
            public int NAME7 { get; set; }
 | 
						|
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 待办统计
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="pageFilter">待办统计</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("getScheduling")]
 | 
						|
        public JsonActionResult<List<schedulingData>> getScheduling([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute<List<schedulingData>>(() =>
 | 
						|
            {
 | 
						|
                dynamic ret = new System.Dynamic.ExpandoObject();
 | 
						|
                var filter1 = new BaseFilter(filter.GetOrgId());
 | 
						|
                filter1.SelectField = new string[] { "ID", "NAME" };
 | 
						|
                var teams = GetEntities<T_FM_TEAM>(t => t.ENABLE_STATUS == 0, filter1);
 | 
						|
 | 
						|
                var filter2 = new BaseFilter(filter.GetOrgId());
 | 
						|
                filter2.SelectField = new string[] { "TEAM_ID", "DATE_TIME", "START_TIME", "END_TIME", "RUN_STATUS", "SHIFT_CLASS_RUN_STATUS" };
 | 
						|
                DateTime today = DateTime.Now.AddDays(-3);
 | 
						|
                var schedulings = GetEntities<T_FM_DEPARTMENT_SCHEDULING>(t => t.DATE_TIME > today, filter2).OrderBy(t => t.START_TIME);
 | 
						|
                List<schedulingData> sDatas = new List<schedulingData>();
 | 
						|
 | 
						|
                foreach (var item in teams)
 | 
						|
                {
 | 
						|
                    var total = schedulings.Where(t => t.TEAM_ID == item.ID);
 | 
						|
                    double totalCount = total.Count();
 | 
						|
                    if (totalCount > 0)
 | 
						|
                    {
 | 
						|
                        schedulingData Data = new schedulingData();
 | 
						|
                        Data.NAME1 = item.NAME;
 | 
						|
                        var day1count = total.Count(t => t.DATE_TIME.Day == DateTime.Now.AddDays(-1).Day);
 | 
						|
                        var day2count = total.Count(t => t.DATE_TIME.Day == DateTime.Now.AddDays(0).Day);
 | 
						|
                        var day3count = total.Count(t => t.DATE_TIME.Day == DateTime.Now.AddDays(1).Day);
 | 
						|
                        var day4count = total.Count(t => t.DATE_TIME.Day == DateTime.Now.AddDays(2).Day);
 | 
						|
                        var day5count = total.Count(t => t.DATE_TIME.Day == DateTime.Now.AddDays(3).Day);
 | 
						|
                        var day6count = total.Count(t => t.DATE_TIME.Day == DateTime.Now.AddDays(4).Day);
 | 
						|
                        var day1 = total.FirstOrDefault(t => t.DATE_TIME.Day == DateTime.Now.AddDays(-1).Day);
 | 
						|
                        var day2 = total.FirstOrDefault(t => t.DATE_TIME.Day == DateTime.Now.AddDays(0).Day);
 | 
						|
                        var day3 = total.FirstOrDefault(t => t.DATE_TIME.Day == DateTime.Now.AddDays(1).Day);
 | 
						|
                        var day4 = total.FirstOrDefault(t => t.DATE_TIME.Day == DateTime.Now.AddDays(2).Day);
 | 
						|
                        var day5 = total.FirstOrDefault(t => t.DATE_TIME.Day == DateTime.Now.AddDays(3).Day);
 | 
						|
 | 
						|
 | 
						|
                        Data.NAME2 = day1 != null ? day1count + "|" + (day1.RUN_STATUS ? "✔" : "❌") + "|" + (day1.SHIFT_CLASS_RUN_STATUS ? "✔" : "❌") + "|" + day1.START_TIME.ToShortTimeString() + "~" + day1.END_TIME.ToShortTimeString() : "";
 | 
						|
                        Data.NAME3 = day2 != null ? day2count + "|" + (day2.RUN_STATUS ? "✔" : "❌") + "|" + (day2.SHIFT_CLASS_RUN_STATUS ? "✔" : "❌") + "|" + day2.START_TIME.ToShortTimeString() + "~" + day2.END_TIME.ToShortTimeString() : "";
 | 
						|
                        Data.NAME4 = day3 != null ? day3count + "|" + (day3.RUN_STATUS ? "✔" : "❌") + "|" + (day3.SHIFT_CLASS_RUN_STATUS ? "✔" : "❌") + "|" + day3.START_TIME.ToShortTimeString() + "~" + day3.END_TIME.ToShortTimeString() : "";
 | 
						|
                        Data.NAME5 = day4 != null ? day4count + "|" + (day4.RUN_STATUS ? "✔" : "❌") + "|" + (day4.SHIFT_CLASS_RUN_STATUS ? "✔" : "❌") + "|" + day4.START_TIME.ToShortTimeString() + "~" + day4.END_TIME.ToShortTimeString() : "";
 | 
						|
                        Data.NAME6 = day5 != null ? day5count + "|" + (day5.RUN_STATUS ? "✔" : "❌") + "|" + (day5.SHIFT_CLASS_RUN_STATUS ? "✔" : "❌") + "|" + day5.START_TIME.ToShortTimeString() + "~" + day5.END_TIME.ToShortTimeString() : "";
 | 
						|
                        Data.NAME7 = day2 != null ? day2.START_TIME.Hour : 0;
 | 
						|
                        sDatas.Add(Data);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                var orderData = sDatas.OrderBy(t => t.NAME1).ThenBy(t=>t.NAME7).ToList();
 | 
						|
                return orderData;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        
 | 
						|
    }
 | 
						|
}
 |