From 835fa8fd00fd559eac29cf93ea78bf3f0b0ab559 Mon Sep 17 00:00:00 2001 From: wyw <571921741@qq.com> Date: Tue, 20 Jan 2026 11:05:15 +0800 Subject: [PATCH] 21 --- .../Api/BIController/BIKanBanController.cs | 492 +++++++++--------- 1 file changed, 241 insertions(+), 251 deletions(-) diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs index bc91946..ceaa2fc 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs @@ -1,51 +1,48 @@ -using APT.BaseData.Domain.Entities; -using APT.BaseData.Domain.Entities.FM; -using APT.BaseData.Domain.Entities.OP; -using APT.BaseData.Domain.Enums; -using APT.BaseData.Domain.IServices.FM; +using APT.BaseData.Domain.Entities; +using APT.BaseData.Domain.Entities.FM; +using APT.BaseData.Domain.Entities.OP; +using APT.BaseData.Domain.Enums; +using APT.BaseData.Domain.IServices.FM; using APT.BaseData.Domain.IServices.OP; -using APT.BaseData.Services.Services.FM; -using APT.Infrastructure.Api; -using APT.Infrastructure.Core; -using APT.Migrations; -using APT.MS.Domain.Entities.BI; -using APT.MS.Domain.Entities.BS; -using APT.MS.Domain.Entities.FO; -using APT.MS.Domain.Entities.HM; -using APT.MS.Domain.Entities.SC.BI; -using APT.MS.Domain.Entities.SE; -using APT.MS.Domain.Enums; -using APT.Utility; -using InfluxData.Net.InfluxDb.Enums; -using log4net.Core; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Data.SqlClient; -using NPOI.SS.Formula.Functions; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Data; +using APT.BaseData.Services.Services.FM; +using APT.Infrastructure.Api; +using APT.Infrastructure.Core; +using APT.Migrations; +using APT.MS.Domain.Entities.BI; +using APT.MS.Domain.Entities.BS; +using APT.MS.Domain.Entities.FO; +using APT.MS.Domain.Entities.HM; +using APT.MS.Domain.Entities.SC.BI; +using APT.MS.Domain.Entities.SE; +using APT.MS.Domain.Enums; +using APT.Utility; +using InfluxData.Net.InfluxDb.Enums; +using log4net.Core; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Data.SqlClient; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Data; using System.Linq; -using static Google.Protobuf.WireFormat; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; -using static NPOI.HSSF.Util.HSSFColor; - -namespace APT.SC.WebApi.Controllers.Api.BI -{ - /// - /// 看板 - /// - [Route("api/BI/BIKanBanController")] - public class BIKanBanController : APTApiController +using static Google.Protobuf.WireFormat; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; +using static NPOI.HSSF.Util.HSSFColor; + +namespace APT.SC.WebApi.Controllers.Api.BI +{ + /// + /// 看板 + /// + [Route("api/BI/BIKanBanController")] + public class BIKanBanController : APTApiController { IOPTenantDBConnService OPTenantDBConnService { get; set; } public BIKanBanController(IOPTenantDBConnService opTenantDBConnService) { OPTenantDBConnService = opTenantDBConnService; } - - #region 属性定义 - /// /// 返回所有 /// @@ -62,91 +59,93 @@ namespace APT.SC.WebApi.Controllers.Api.BI //作业现场完成情况统计 public List jobFinishRate { get; set; } //各公司安全检查统计 - public List safeCheckSum { get; set; } - - public List listSETrainSum { get; set; } - - } - + public List safeCheckSum { get; set; } + /// + /// 培训教育 + /// + public List listSETrainSum { get; set; } + } + /// /// 风险等级占比 - /// - public class RiskTypeRate - { - public string riskType { get; set; } - public int count { get; set; } - public string rate { get; set; } + /// + public class RiskTypeRate + { + public string riskType { get; set; } + public int count { get; set; } + public string rate { get; set; } } /// /// 当日工作票排名前三 - /// - public class JobTodayTop3 + /// + public class JobTodayTop3 { public int totalQty { get; set; } - public int num { get; set; } - public string company { get; set; } - public List details { get; set; } - } - public class JobTodayDetail + public int num { get; set; } + public string company { get; set; } + public List details { get; set; } + } + public class JobTodayDetail { - public string company { get; set; } - public string jobName { get; set; } - public int qty { get; set; } + public string company { get; set; } + public string jobName { get; set; } + public int qty { get; set; } } /// /// 隐患整改率 - /// - public class HiddenRectify + /// + public class HiddenRectify { public int qty { get; set; } public int ontimeQty { get; set; } public int delayQty { get; set; } - public string rate { get; set; } + public string rate { get; set; } } /// /// 各事项排名前三 - /// - public class TaskTopTemp + /// + public class TaskTopTemp { public int totalQty { get; set; } - public int qty { get; set; } + public int qty { get; set; } public string company { get; set; } - public string type { get; set; } - } - public class TaskTop3 + public string type { get; set; } + } + public class TaskTop3 { - public int totalQty { get; set; } - public string company { get; set; } - public List details { get; set; } - } - public class TaskTopDetail - { - public string name { get; set; } - public int qty { get; set; } + public int totalQty { get; set; } + public string company { get; set; } + public List details { get; set; } + } + public class TaskTopDetail + { + public string name { get; set; } + public int qty { get; set; } } /// /// 作业现场完成情况统计 - /// - public class JobFinishRate - { - public string name { get; set; } + /// + public class JobFinishRate + { + public string name { get; set; } public int qty { get; set; } public int finishQty { get; set; } - public string rate { get; set; } + public string rate { get; set; } } /// /// 各公司安全检查统计 /// - public class SafeCheckSum - { - public string company { get; set; } + public class SafeCheckSum + { + public string company { get; set; } public int qty { get; set; } - public int num { get; set; } + public int num { get; set; } } + /// /// 培训教育学时获取 /// @@ -224,16 +223,14 @@ namespace APT.SC.WebApi.Controllers.Api.BI } - #endregion - - /// - /// 返回看板所有接口 - /// - /// 分页过滤实体 - /// - [HttpPost, Route("ReturnAllData")] - public ReturnAll ReturnAllData([FromBody] KeywordFilter filter) - { + /// + /// 返回看板所有接口 + /// + /// 分页过滤实体 + /// + [HttpPost, Route("ReturnAllData")] + public ReturnAll ReturnAllData([FromBody] KeywordFilter filter) + { ReturnAll result = new ReturnAll(); var ListAllORG = GetEntities(e => !e.IS_DELETED && e.CODE != "003", null, null).OrderBy(e => e.TENANT_CODE).ToList(); string strConn = OPTenantDBConnService.GetConnByORGID(filter.OrgId.Value);//获取数据库链接 @@ -250,8 +247,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI string connhead = ConfigurationManager.ConnectionStrings["head"];//删除吧 TPM是没有相对于配置 //风险等级占比 - result.riskTypeRate = RiskTypeRateData(strConn); - + result.riskTypeRate = RiskTypeRateData(connhead); //当日工作票排名前三 result.jobTodayTop3 = JobTodayTopData(connhead, filter.OrgId.Value); //隐患整改率 @@ -263,7 +259,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI //各公司安全检查统计 result.safeCheckSum = safeCheckSumData(connhead); - return result; + return result; } /// @@ -296,25 +292,22 @@ namespace APT.SC.WebApi.Controllers.Api.BI } connection.Close(); } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + catch (Exception ex) + { + if (!string.IsNullOrEmpty(ex.StackTrace)) + throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); + else + throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); } } } - #region 子方法 - - - /// - /// 风险等级占比 - /// - /// 分页过滤实体 - public List RiskTypeRateData(string connhead) - { + /// + /// 风险等级占比 + /// + /// 分页过滤实体 + public List RiskTypeRateData(string connhead) + { List result = new List(); DataTable Table = new DataTable(); using (SqlConnection connection = new SqlConnection(connhead)) @@ -334,37 +327,37 @@ namespace APT.SC.WebApi.Controllers.Api.BI Data.Fill(Table); } connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - result.Add(new RiskTypeRate() - { - riskType = item["风险类别"] != null ? item["风险类别"].ToString() : null, - count = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, - rate = item["占比"] != null ? item["占比"].ToString() : "0" - }); - } + if (Table != null && Table.Rows.Count > 0) + { + foreach (DataRow item in Table.Rows) + { + result.Add(new RiskTypeRate() + { + riskType = item["风险类别"] != null ? item["风险类别"].ToString() : null, + count = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, + rate = item["占比"] != null ? item["占比"].ToString() : "0" + }); + } } } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + 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 result; + return result; } - /// - /// 当日工作票排名前三 - /// - /// 参数 - /// - public List JobTodayTopData(string connhead, Guid orgId) - { + /// + /// 当日工作票排名前三 + /// + /// 参数 + /// + public List JobTodayTopData(string connhead, Guid orgId) + { List result = new List(); var details = new List(); DataTable Table = new DataTable(); @@ -397,16 +390,16 @@ namespace APT.SC.WebApi.Controllers.Api.BI Data.Fill(Table2); } connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - var JobTodayTop3 = new JobTodayTop3(); - JobTodayTop3.totalQty = int.Parse(item["今日总数"].ToString()) != 0 ? int.Parse(item["今日总数"].ToString()) : 0; - JobTodayTop3.num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0; - JobTodayTop3.company = item["公司名称"] != null ? item["公司名称"].ToString() : ""; - result.Add(JobTodayTop3); - } + if (Table != null && Table.Rows.Count > 0) + { + foreach (DataRow item in Table.Rows) + { + var JobTodayTop3 = new JobTodayTop3(); + JobTodayTop3.totalQty = int.Parse(item["今日总数"].ToString()) != 0 ? int.Parse(item["今日总数"].ToString()) : 0; + JobTodayTop3.num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0; + JobTodayTop3.company = item["公司名称"] != null ? item["公司名称"].ToString() : ""; + result.Add(JobTodayTop3); + } } if (Table2 != null && Table2.Rows.Count > 0) { @@ -441,23 +434,23 @@ namespace APT.SC.WebApi.Controllers.Api.BI } } } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + 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 result; + return result; } - /// - /// 隐患整改率 - /// - /// 参数 - /// - public HiddenRectify HiddenRectifyData(string connhead) + /// + /// 隐患整改率 + /// + /// 参数 + /// + public HiddenRectify HiddenRectifyData(string connhead) { HiddenRectify result = new HiddenRectify(); DataTable Table = new DataTable(); @@ -478,32 +471,32 @@ namespace APT.SC.WebApi.Controllers.Api.BI Data.Fill(Table); } connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { + if (Table != null && Table.Rows.Count > 0) + { result.qty = int.Parse(Table.Rows[0]["隐患数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["隐患数"].ToString()) : 0; - result.ontimeQty = int.Parse(Table.Rows[0]["按期整改数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["按期整改数"].ToString()) : 0; + result.ontimeQty = int.Parse(Table.Rows[0]["按期整改数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["按期整改数"].ToString()) : 0; result.delayQty = int.Parse(Table.Rows[0]["延期整改数"].ToString()) != 0 ? int.Parse(Table.Rows[0]["延期整改数"].ToString()) : 0; result.rate = Table.Rows[0]["整改率"] != null ? Table.Rows[0]["整改率"].ToString() : null; } } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + 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 result; + return result; } - /// - /// 各事项排名前三 - /// - /// 参数 - /// - public List TaskTopData(string connhead) - { + /// + /// 各事项排名前三 + /// + /// 参数 + /// + public List TaskTopData(string connhead) + { List result = new List(); var dataTemps = new List(); DataTable Table = new DataTable(); @@ -524,17 +517,17 @@ namespace APT.SC.WebApi.Controllers.Api.BI Data.Fill(Table); } connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - var JobTodayTop3 = new TaskTopTemp(); + if (Table != null && Table.Rows.Count > 0) + { + foreach (DataRow item in Table.Rows) + { + var JobTodayTop3 = new TaskTopTemp(); JobTodayTop3.totalQty = int.Parse(item["待办总数"].ToString()) != 0 ? int.Parse(item["待办总数"].ToString()) : 0; JobTodayTop3.qty = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0; JobTodayTop3.company = item["公司名称"] != null ? item["公司名称"].ToString() : ""; - JobTodayTop3.type = item["类型"] != null ? item["类型"].ToString() : ""; - dataTemps.Add(JobTodayTop3); - } + JobTodayTop3.type = item["类型"] != null ? item["类型"].ToString() : ""; + dataTemps.Add(JobTodayTop3); + } } if (dataTemps != null && dataTemps.Any()) { @@ -561,25 +554,25 @@ namespace APT.SC.WebApi.Controllers.Api.BI } } } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + 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 result; + return result; } - /// - /// 作业现场完成情况统计 - /// - /// 参数 - /// - public List jobFinishRateData(string connhead) - { + /// + /// 作业现场完成情况统计 + /// + /// 参数 + /// + public List jobFinishRateData(string connhead) + { List result = new List(); DataTable Table = new DataTable(); using (SqlConnection connection = new SqlConnection(connhead)) @@ -599,39 +592,39 @@ namespace APT.SC.WebApi.Controllers.Api.BI Data.Fill(Table); } connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - result.Add(new JobFinishRate() - { - name = item["表单名称"] != null ? item["表单名称"].ToString() : null, - qty = int.Parse(item["总数"].ToString()) != 0 ? int.Parse(item["总数"].ToString()) : 0, + if (Table != null && Table.Rows.Count > 0) + { + foreach (DataRow item in Table.Rows) + { + result.Add(new JobFinishRate() + { + name = item["表单名称"] != null ? item["表单名称"].ToString() : null, + qty = int.Parse(item["总数"].ToString()) != 0 ? int.Parse(item["总数"].ToString()) : 0, finishQty = int.Parse(item["完成数"].ToString()) != 0 ? int.Parse(item["完成数"].ToString()) : 0, - rate = item["完成率"] != null ? item["完成率"].ToString() : null, - }); - } + rate = item["完成率"] != null ? item["完成率"].ToString() : null, + }); + } } } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + 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 result; + return result; } - /// - /// 各公司安全检查统计 - /// - /// 参数 - /// - public List safeCheckSumData(string connhead) - { + /// + /// 各公司安全检查统计 + /// + /// 参数 + /// + public List safeCheckSumData(string connhead) + { List result = new List(); DataTable Table = new DataTable(); using (SqlConnection connection = new SqlConnection(connhead)) @@ -651,28 +644,28 @@ namespace APT.SC.WebApi.Controllers.Api.BI Data.Fill(Table); } connection.Close(); - if (Table != null && Table.Rows.Count > 0) - { - foreach (DataRow item in Table.Rows) - { - result.Add(new SafeCheckSum() - { - company = item["公司名称"] != null ? item["公司名称"].ToString() : null, - qty = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, - num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0, - }); - } + if (Table != null && Table.Rows.Count > 0) + { + foreach (DataRow item in Table.Rows) + { + result.Add(new SafeCheckSum() + { + company = item["公司名称"] != null ? item["公司名称"].ToString() : null, + qty = int.Parse(item["数量"].ToString()) != 0 ? int.Parse(item["数量"].ToString()) : 0, + num = int.Parse(item["排名"].ToString()) != 0 ? int.Parse(item["排名"].ToString()) : 0, + }); + } } } - catch (Exception ex) - { - if (!string.IsNullOrEmpty(ex.StackTrace)) - throw new Exception("错误日志:[StackTrace]" + ex.StackTrace); - else - throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message); + 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 result; + return result; } /// @@ -713,8 +706,5 @@ namespace APT.SC.WebApi.Controllers.Api.BI } return dtInfo; } - - - #endregion - } -} + } +}