This commit is contained in:
wyw 2026-01-20 11:05:15 +08:00
parent 8dcbfd8bc4
commit 835fa8fd00

View File

@ -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
{
/// <summary>
/// 看板
/// </summary>
[Route("api/BI/BIKanBanController")]
public class BIKanBanController : APTApiController<T_FM_NOTIFICATION_TASK>
using static Google.Protobuf.WireFormat;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
using static NPOI.HSSF.Util.HSSFColor;
namespace APT.SC.WebApi.Controllers.Api.BI
{
/// <summary>
/// 看板
/// </summary>
[Route("api/BI/BIKanBanController")]
public class BIKanBanController : APTApiController<T_FM_NOTIFICATION_TASK>
{
IOPTenantDBConnService OPTenantDBConnService { get; set; }
public BIKanBanController(IOPTenantDBConnService opTenantDBConnService)
{
OPTenantDBConnService = opTenantDBConnService;
}
#region
/// <summary>
/// 返回所有
/// </summary>
@ -62,91 +59,93 @@ namespace APT.SC.WebApi.Controllers.Api.BI
//作业现场完成情况统计
public List<JobFinishRate> jobFinishRate { get; set; }
//各公司安全检查统计
public List<SafeCheckSum> safeCheckSum { get; set; }
public List<SETRAINSHOW> listSETrainSum { get; set; }
}
public List<SafeCheckSum> safeCheckSum { get; set; }
/// <summary>
/// 培训教育
/// </summary>
public List<SETRAINSHOW> listSETrainSum { get; set; }
}
/// <summary>
/// 风险等级占比
/// </summary>
public class RiskTypeRate
{
public string riskType { get; set; }
public int count { get; set; }
public string rate { get; set; }
/// </summary>
public class RiskTypeRate
{
public string riskType { get; set; }
public int count { get; set; }
public string rate { get; set; }
}
/// <summary>
/// 当日工作票排名前三
/// </summary>
public class JobTodayTop3
/// </summary>
public class JobTodayTop3
{
public int totalQty { get; set; }
public int num { get; set; }
public string company { get; set; }
public List<JobTodayDetail> details { get; set; }
}
public class JobTodayDetail
public int num { get; set; }
public string company { get; set; }
public List<JobTodayDetail> 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; }
}
/// <summary>
/// 隐患整改率
/// </summary>
public class HiddenRectify
/// </summary>
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; }
}
/// <summary>
/// 各事项排名前三
/// </summary>
public class TaskTopTemp
/// </summary>
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<TaskTopDetail> 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<TaskTopDetail> details { get; set; }
}
public class TaskTopDetail
{
public string name { get; set; }
public int qty { get; set; }
}
/// <summary>
/// 作业现场完成情况统计
/// </summary>
public class JobFinishRate
{
public string name { get; set; }
/// </summary>
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; }
}
/// <summary>
/// 各公司安全检查统计
/// </summary>
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; }
}
/// <summary>
/// 培训教育学时获取
/// </summary>
@ -224,16 +223,14 @@ namespace APT.SC.WebApi.Controllers.Api.BI
}
#endregion
/// <summary>
/// 返回看板所有接口
/// </summary>
/// <param name="filter">分页过滤实体</param>
/// <returns></returns>
[HttpPost, Route("ReturnAllData")]
public ReturnAll ReturnAllData([FromBody] KeywordFilter filter)
{
/// <summary>
/// 返回看板所有接口
/// </summary>
/// <param name="filter">分页过滤实体</param>
/// <returns></returns>
[HttpPost, Route("ReturnAllData")]
public ReturnAll ReturnAllData([FromBody] KeywordFilter filter)
{
ReturnAll result = new ReturnAll();
var ListAllORG = GetEntities<T_FM_ORGANIZATION>(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;
}
/// <summary>
@ -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
/// <summary>
/// 风险等级占比
/// </summary>
/// <param name="filter">分页过滤实体</param>
public List<RiskTypeRate> RiskTypeRateData(string connhead)
{
/// <summary>
/// 风险等级占比
/// </summary>
/// <param name="filter">分页过滤实体</param>
public List<RiskTypeRate> RiskTypeRateData(string connhead)
{
List<RiskTypeRate> result = new List<RiskTypeRate>();
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;
}
/// <summary>
/// 当日工作票排名前三
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<JobTodayTop3> JobTodayTopData(string connhead, Guid orgId)
{
/// <summary>
/// 当日工作票排名前三
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<JobTodayTop3> JobTodayTopData(string connhead, Guid orgId)
{
List<JobTodayTop3> result = new List<JobTodayTop3>();
var details = new List<JobTodayDetail>();
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;
}
/// <summary>
/// 隐患整改率
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public HiddenRectify HiddenRectifyData(string connhead)
/// <summary>
/// 隐患整改率
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
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;
}
/// <summary>
/// 各事项排名前三
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<TaskTop3> TaskTopData(string connhead)
{
/// <summary>
/// 各事项排名前三
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<TaskTop3> TaskTopData(string connhead)
{
List<TaskTop3> result = new List<TaskTop3>();
var dataTemps = new List<TaskTopTemp>();
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;
}
/// <summary>
/// 作业现场完成情况统计
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<JobFinishRate> jobFinishRateData(string connhead)
{
/// <summary>
/// 作业现场完成情况统计
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<JobFinishRate> jobFinishRateData(string connhead)
{
List<JobFinishRate> result = new List<JobFinishRate>();
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;
}
/// <summary>
/// 各公司安全检查统计
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<SafeCheckSum> safeCheckSumData(string connhead)
{
/// <summary>
/// 各公司安全检查统计
/// </summary>
/// <param name="filter">参数</param>
/// <returns></returns>
public List<SafeCheckSum> safeCheckSumData(string connhead)
{
List<SafeCheckSum> result = new List<SafeCheckSum>();
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;
}
/// <summary>
@ -713,8 +706,5 @@ namespace APT.SC.WebApi.Controllers.Api.BI
}
return dtInfo;
}
#endregion
}
}
}
}